Archive for Ruby & Ruby on Rails

Using Paperclip in Rails 3 on Windows

After spending several hours trying to get this nifty plugin to run and scouring the internet for solutions, I’ve decided to publish what I found, even if it doesn’t fit with the general theme of this blog.

First off, let me state that Paperclip, contrary to expectations, only needs ImageMagick, not RMagick, though you’re better off installing ImageMagick from the RMagick installer for Windows so that you don’t have version conflicts later if you need RMagick for something else. Furthermore, ImageMagick does NOT need to be referenced in your Gemfile, or required in application.rb .

You DO however need to refer to the ImageMagick directory in order to get Paperclip to run. This is done by putting
Paperclip.options[:command_path] = 'E:/Ruby192/ImageMagick' (or similar) into your development.rb, otherwise you will get the usual “is not recognized by the ‘identify’ command” error. It appears to be vital that the path to ImageMagick does NOT contain spaces.

Obviously this is going to be annoying if you’re part of a team of developers using different operating systems. I saw one post advocating the use of
if RUBY_PLATFORM =~ /mswin/
in order to be able to specify a different path for Windows users, but this does not work for me.



No comment »