Ruby 1.9.2 lambda with clip

I upgrade my working application to 1.9.2, but I can not find the answer to the following:

I create an object like this in my controller:

@asset = Asset.new(params) 

and then in my model use lambda to dynamically create such styles:

 has_attached_file :asset, :styles => lambda { |attachment| attachment.instance.choose_styles} 

Then I check the specific value that was in my parameters:

 def choose_styles if self.item_name == 'Car' { :small => ["200x200>"], :medium => ["400x400>"], :large => ["700x700>"], :full_screen => ["1000x700>"] } else ........ end 

Problem: item_name is nil in 1.9.2 until it is done, and then appears to be set from the parameters. It all works with switching to 1.8.7

Can anyone see to help me?

thanks Rick

+4
source share
1 answer

I know this is not an answer that matches your question. By the way, you can switch to the carrier ( https://github.com/jnicklas/carrierwave ). You can select formats in more detail by creating different versions and inserting them.

As an example, ipothetic AssetUploader could be:

 ... version :thumb_200x200 do process :resize_to_fill => [200,200] end version :big_600x600 do ... 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 is just an example of code, tailored to your needs;)

amuses, A.

0
source

All Articles