Forum: Ruby on Rails attachment_fu - propagating attributes to thumbnails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
jstepper (Guest)
on 2007-04-18 02:39
(Received via mailing list)
I have a model using attachment_fu (via has_attachment) and I'm
creating thumbnails for the attached images.  I have an extra field
'foo' that I'm validating on create with validates_presence_of :foo.

One problem arises when I upload an image:

The 'foo' is not propogating down to the thumbnails.  What should I
put in my model to grab the parent's (via parent_id) 'foo' if no foo
is provided?

Thanks in advance.
Jimtron (Guest)
on 2007-04-28 17:57
(Received via mailing list)
I'm not sure if this is what you're looking for, but I had a similar
problem giving a thumbnail
the foreign key of its parent. Try this in the model that's using
attachment_fu:

before_thumbnail_saved do |record, thumbnail|
    thumbnail.foo = record.foo
end
This topic is locked and can not be replied to.