Practical Paperclip

Paperclip is a great rails plugin for attaching files to your models. I won’t reiterate the basic functionality: see the link for that, it’s really just that easy. That said, I did note a couple things that could be practical to keep in mind for development.

1. Remember to add system/* to your .gitignore file (or the equivalent for your SCM of choice), or else you’ll wind up moving a whole lot of test images and/or other files to your repository.

2. I started using Phusion Passenger locally, and noticed that Paperclip’s image resizing suddenly stopped working; model.image.url(:thumb) (for example) didn’t exist anymore. It turns out that to resolve this you can create paperclip.rb in config/initializers and add:

1
2
3
if RAILS_ENV == "development"
  Paperclip.options[:image_magick_path] = '/opt/local/bin' # or your path to ImageMagick
end

0 Responses to “Practical Paperclip”


Comments are currently closed.



Fork me on GitHub