Using Rails 2, I try to separate different, dynamic image sizes trough another Model from the Paperclip-Model. My current approach, using a Proc, looks the following:
class File < ActiveRecord::Base
has_many :sizes, :class_name => "FileSize"
has_attached_file(
:attachment,
:styles => Proc.new { |instance| instance.attachment_sizes }
)
def attachment_sizes
sizes = { :thumb => ["100x100"] }
self.sizes.each do |size|
sizes[:"#{size.id}"] = ["#{size.width}x#{size.height}"]
end
sizes
end
end
class FileSize < ActiveRecord::Base
belongs_to :file
after_create :reprocess
after_destroy :reprocess
private
def reprocess
self.file.attachment.reprocess!
end
end
Everything seems to work out fine but apparently no styles are processed and no image is being created.
Did anyone manage doing stuff like this?
-- Update --
Obviously the method attachment_sizes on instance sometimes is not defined for # - but shouldn't instance actually be #? For me this looks like altering instance..