I'm going through Mattan Griffel's "One Month Rails" (http://onemonthrails.com/) class. I'm trying to use the paperclip gem to upload images. Initial install and usage went fine, until he added a line to reduce the size of images. This was placed in app/models/pin.rb as shown in his tutorial:
has_attached_file :image, styles: { medium: "320x240>" }
It worked until the styles: {} part was added. I have also updated my partial to pass in the :medium method.
I'm using: paperclip (3.4.1),cocaine (0.5.1) and rails (3.2.12). I have seen other posts where this was fixed with homebrew, but I'm on a Windows 7 machine and I'm fairly certain that doesn't apply. Let me know if I need to post anything else.
I'm following the same course. After several gem changes (trying older versions of cocaine, etcetera...) the thing that solved my problem was adding this line to pin.rb:
Paperclip.options[:command_path] = 'C:/Program Files/ImageMagick-6.8.5-Q16'
before belongs_to :user
(change the path for your image magick install path)
After this, run a bundle update and reset your rails server.
Add
Paperclip.options[:command_path] = 'C:/Program Files/ImageMagick-6.8.9-Q16'
to this file.
\config\environments\development.rb
Make sure to run
which convert
so you know what version number and don't copy and paste another version number.
Restart your rails server
Though it showed the path when I ran which convert
, I download the ImageMagick and installed it separately and gave the path and added the line as mentioned by q256 and it worked!
I was using version 6.7.9
of ImageMagick. So in addition to adding the command_path, I had to update to the latest version of ImageMagick i.e 6.8.8
Just to expand on q256's answer, updating this file might cause it to break on heroku when you do a push, because the live-on-the-internet server won't know how to find a program installed on your local hard drive.
The more correct way (at least that I have found) to fix this issue for windows users is to update the development.rb file under config->environments->development.rb and throw the line in at the end of the file.
Paperclip.options[:command_path] = 'C:/Program Files/ImageMagick-6.8.5-Q16'
Hope that helps someone, and don't forget to restart your rails server after saving the file, note that a bundle update isn't required.
来源:https://stackoverflow.com/questions/16072338/papercliperrorsnotidentifiedbyimagemagickerror-on-windows-7