Spree Commerce

Try It Now

Goodbye attachment_fu ... Hello paperclip

Posted on December 04, 2008 by Sean Schofield

Spree now uses paperclip to manage its image attachments. Up until this point we had been using the venerable attachment_fu. We were pleased enough with attachment_fu until we discovered that someone had forked Spree in Github and created a patch to use paperclip.

Well we did a little digging and found an interesting blog post. Attachment_fu relies on the mini_magick gem which the Thought Bot folks suspect causes memory issues. When we looked at it we saw the opportunity for one less gem dependency and a slightly cleaner implementation.

Bobby Santiago (bullrico) was kind enough to supply the excellent patch. He’s also made it easy to tweak so that you can upload all sorts of generic assets (not just images.)

Fair warning, the new migrations will totally reorganize your image records and move things around on your filesystem. Product images will be moved from public/images/products to public/assets/products. We’ve tested the migration the best we can but you never know what we might have missed. If you have a lot of real world assets you should back up your filesystem and database before attempting the migration.