Tag Archives: Paperclip

Not Recognised by the ‘identify’ command – Paperclip

Just a quick post on another problem I ran into while setting up PaperClip. When attempting to submit a form WITHOUT an image I received the following error message:

Assets asset /tmp/stream20120218-22611-dgnkr-0.exe is not recognized by the 'identify' command.

Apparently the most common cause of this issue is one of two things:

#1: You don’t have RMagick installed
The easiest fix for this is to simply install the rmagick gem. Simply add rmagick to your Gemfile and run bundle install. Restart your server and you should be ready to go.

#2: Your command_path isn’t set correctly
Run the following command from your console:

chris@chris-VirtualBox:~/site$ which identify

Then add the path that is returned to your environment settings:

Paperclip.options[:command_path] = "/usr/bin"

#3: If all else fails

If none of the above seem to be causing your issue, try adding the following to your model:

 def asset?
    !(asset_content_type =~ /^image.*/).nil?

This will simply prevent the file being processed if it’s not an image, avoiding the issue all together. Hopefully this’ll help someone out, let me know if you come across any other solutions.

Apparently a more recent cause of this issue is an update to the cocaine gem, rolling back to version 0.3.2 appears to resolve the issue. Thanks to Ahmed and Fabrice for bringing it to my attention:


PaperClip Issues – Ruby on Rails

I finally decided to replace all my existing code to handle images with Paperclip. I was following the screencast by Emerson Lackey, #134 Paperclip, however I ran into a couple of issues. Thankfully they were all very easily fixed, and probably wouldn’t have occurred at all if I’d simply watched the whole screencast instead of trying to rush on ahead.

Issue #1:
The first issue I encountered was that my asset fields weren’t appearing on the page:


I spent way too much time trying to work this one out, especially considering how obvious the solution is – the screencast is simply missing an “=” after the initial “<%" in "<% f.fields_for". Simply amend it as follows:


Issue #2:
The second one is actually encountered and addressed by Emerson himself. Unfortunately I started trying to find a solution before seeing his, so just in case someone else does a Google search I’ll include the issue here:

undefined method `symbolize_keys!' for "/system/assets/1/original/mack_truck.jpg?1329550205":String


The problem here is simply that the parenthesis are in the wrong place, simply amend your code as follows:


Anyway, hopefully this helps someone else out – let me know if there are any issues.

Update: Don’t name your model assets!
Unfortunately I followed the tutorials naming example and called my model Asset. While this may have been fine in earlier version of rails it causes quirky conflicts with the asset pipeline. I strongly encourage you to use a different name i.e. Uploads