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


Posted

in

, , ,

by

Comments

One response to “PaperClip Issues – Ruby on Rails”

  1. Daryl Avatar
    Daryl

    I was having the problem that the file upload fields were not showing up.

    You saved me a lot of time. Thank you.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

%d bloggers like this: