ruby 1.9.2 lambda with paperclip -
i upgrading working app 1.9.2 can't find answer following :
i create asset in controller :
@asset = asset.new(params)
and in model use lambda dynamically generate styles :
has_attached_file :asset, :styles => lambda { |attachment| attachment.instance.choose_styles}
then check value in params so:
def choose_styles if self.item_name == 'car' { :small => ["200x200>"], :medium => ["400x400>"], :large => ["700x700>"], :full_screen => ["1000x700>"] } else ........ end
the problem item_name nil in 1.9.2 till after has been run seems set params. works switching 1.8.7
is can see me please ??
thank rick
i know not answer fits question. way, can switch carrierwave (https://github.com/jnicklas/carrierwave). can choose formats in more granular way creating various versions , nesting them.
as example, ipothetic assetuploader be:
... version :thumb_200x200 process :resize_to_fill => [200,200] end version :big_600x600 ... end ... version :car, :if => in_category(:car)? version :thumb_200x200 version :another_etc end ... protected def in_category?(name) model.item_name.downcase == name.to_s end ...
this example of code, adjust needs ;)
cheers, a.
Comments
Post a Comment