So here is the situation:
The Photo model in Community Engine is using attachment Fu. I, wish to use paperclip instead.
Now this works fine until I have to delete an attachment. That's when the attachment Fu is causing the problem. Here is what Photo.rb looks like (in /vendor/plugins/community_engine/app/models):
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
So my question is: Is there a way to disable this plugin? I don't want to change photo.rb and delete any lines, nor do I want to remove the plugin.
Any ideas here?
New Photo Model (in /app/):
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
New Photo Controller (in /app/):
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
If you installed the plugin to your
vendor/
directory, then find the plugin under theplugins/
subdirectory and comment out everything in theinit.rb
. This should disable all functionality of the plugin without removing it from your source tree.