Update: This post was written based on an older version of paperclip which didn’t have a default rake task for this.
I’ve been using the Paperclip plugin/ gem for image attachment in several of my apps and I’ve encountered a scenario wherein I needed to change one of the styles configured in the model to accommodate the client’s request. At that point, there are already a bunch of images in the project so I need to resize or in Paperclip’s terms reprocess all of them to fit the new configuration.
Here’s how I did it:
If you have paperclip installed as a plugin
If Paperclip is installed as a plugin, you can do this:
rake paperclip:refresh:thumbnails CLASS=Attachment
Just replace Attachment with whatever classname you are using for with Paperclip
If it’s installed as a gem, do this inside script/console:
Attachment.all.each {|s| s.logo.reprocess! if s.logo}
Just replace Attachment with whatever class name you are using for with Paperclip and logo with whatever attribute name you are using for the image.
And you’re done 🙂
September 28, 2012 at 5:23 pm
I installed paperclip as a gem and rake -T tells me that i have paperclip:refresh:thumbnails task available.
September 28, 2012 at 5:48 pm
I guess they added it along the way. In any case, thanks for the heads up. I’ve added a notice up top.