1

여기 상황은 다음과 같습니다.첨부 파일 Fu 플러그인을 제거하지 않고 커뮤니티 엔진에서 어떻게 비활성화합니까?

사진 엔진이 첨부 파일 Fu를 사용하고 있습니다. 나는 대신에 종이 클립을 사용하고 싶다.

첨부 파일을 삭제해야만 정상적으로 작동합니다. 그 때 Fu가 문제를 일으키는 것입니다. 여기 Photo.rb은 (/ 공급 업체/플러그인/community_engine/응용 프로그램에서/모델) 모습입니다 :

class Photo < ActiveRecord::Base 


    acts_as_commentable 
    belongs_to :album 

    has_attachment prepare_options_for_attachment_fu(AppConfig.photo['attachment_fu_options']) 

    acts_as_taggable 

    acts_as_activity :user, :if => Proc.new{|record| record.parent.nil? && record.album_id.nil?} 

    validates_presence_of :size 
    validates_presence_of :content_type 
    validates_presence_of :filename 
    validates_presence_of :user, :if => Proc.new{|record| record.parent.nil? } 
    validates_inclusion_of :content_type, :in => attachment_options[:content_type], :message => "is not allowed", :allow_nil => true 
    validates_inclusion_of :size, :in => attachment_options[:size], :message => " is too large", :allow_nil => true 

... 
... 

end 

그래서 내 질문은 :이 플러그인을 사용하지 않도록 설정하는 방법이 있나요? 나는 photo.rb를 바꾸고 모든 라인을 삭제하거나 플러그인을 제거하고 싶지 않습니다.

여기에 아이디어가 있습니까?

새로운 사진 모델 (에/응용 프로그램 /) :

require 'paperclip_processors/cropper' 

class Photo < ActiveRecord::Base 

    attr_accessible :image 
    has_attached_file :image,  
        :path=>":class/:hash/:style.:extension", 
        :styles => { 
         :thumb => {:geometry => "100x100!", :crop_to => :crop_parameters}, 
         :medium => {:geometry => "290x320!", :crop_to => :crop_parameters}, 
         :large => {:geometry => "664>", :crop_to => :crop_parameters}, 
         :uncropped => "630x472" 
        }, 
        :convert_options=>'-quality 92', 
        :processors => [:cropper] 

    def crop_parameters 
    ActiveSupport::JSON.decode(read_attribute(:crop_parameters)) rescue nil 
    end 


# overrides to make paperclip appear as attachment_fu to existing pages   

    def size # in MB 
    image_file_size 
    end 
    def filename 
    image_file_name 
    end 
    def content_type 
    image_content_type 
    end 


    def public_filename(size=:original) 
    image.url(size) || "" 
    end 

end 

새로운 사진 컨트롤러 (에/응용 프로그램 /) :

require 'pp' 

class PhotosController < BaseController 
    before_filter :use_paperclip, :only => [:create] 

    def use_paperclip 
    params[:photo][:image] = params[:photo][:uploaded_data] 
    params[:photo].delete(:uploaded_data)  
    end 

end 

답변

0

당신이 당신의 vendor/ 디렉토리에 플러그인을 설치 한 경우, 다음를 찾아서 플러그인은 plugins/ 하위 디렉토리 아래에 있으며 init.rb의 모든 내용을 주석으로 처리하십시오. 이렇게하면 소스 트리에서 제거하지 않고 플러그인의 모든 기능을 사용할 수 없도록 설정해야합니다.

+0

내가 듣고 있지만 attachmentfu가 Community Engine Plugin의 플러그인으로 설치되었습니다. – Gbert90

0

클립 클립을 사용하고 있는데, 클립 클립을 초기화하지 않은 경우 정확하게 사용하고 있습니까?

이니셜 라이저에서 클래스를 열고 필요에 맞게 클래스를 변경할 수 있습니다.

구성 파일에서 설정 한 어댑터 패턴을 사용하여 첨부 파일 코드를 추가하는 것이 더 좋을 수 있으므로 모듈을 만들어 포함 할 수 있습니다. 이 모듈은 여러분이 생성 한 설정에 따라 클립 또는 첨부 파일을 포함할지 여부, 그리고 매개 변수를 초기화 할 위치를 결정합니다.

+0

위 질문에 코드를 추가했습니다. 제발 좀 봐주세요? – Gbert90