Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paperclip for Rails: Can I access the model?

Let's say I have a model called Theme, which has several attributes setting interface colors. Theme also has a Paperclip attachment, which is a user-generated CSS template. I want to set up a processor to generate a final CSS file, inserting the interface colors into the user-generated template. To do this, I need to access the model data from within the processor. Is this possible?

like image 774
jeffpatt Avatar asked Sep 30 '09 07:09

jeffpatt


1 Answers

The processor has an accessor called attachment this points back to the instance of Paperclip::Attachment. The attachment in turn has an accessor instance which points to the instance of the original model. So all you should have to do from the processor is call attachment.instance to get the original model.

like image 67
Peter Wagenet Avatar answered Sep 21 '22 12:09

Peter Wagenet