Using Rails 2, I am trying to separate different, dynamic image sizes through another model from the Paperclip model. My current approach using Proc is as follows:
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 just fine, but apparently not a single style is being processed and the image is not created.
Has anyone helped do such things?
- Update -
Obviously, the attachment_sizes method in an instance is sometimes not defined for #, but should not be an actual # instance? For me it looks like a modifying instance.
source share