Got it!
This was a tricky one. I'll post the solution here since I've seen
some other posts where people got unsatisfactory results. I'm pleased
with how this came out. Here is my ProductImage class, in its
entirety.
class ProductImage < ActiveRecord::Base
belongs_to :product
acts_as_list
has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 500.kilobytes,
:resize_to => '480!x360!',
:thumbnails => {
:medium => '247!x185!',
:small => '80!x60!',
:micro => '44!x33!'
}
validates_as_attachment
def scope_condition
product_condition = product_id.nil? ? "product_id is null" :
"product_id = #{product_id}"
product_condition + " and parent_id is null"
end
end
The magic is in the scope_condition method that sensibly handles when
we don't have a product_id (i.e., on the thumbnails that are getting
ripped out).
-Eric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---