여기 상황은 다음과 같습니다.첨부 파일 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
내가 듣고 있지만 attachmentfu가 Community Engine Plugin의 플러그인으로 설치되었습니다. – Gbert90