1
votes

I am unable to get Paperclip to save my attachment. Rather than saving a single image (such as an avatar as seems to be the common usage), I need to be able to upload/save multiple files; therefore I have a User model and an Asset model. The file information gets properly stored in the asset table, but the attachment itself is not saved in the filesystem as expected.

My log shows the message: "[paperclip] Saving attachments." but the attachment is not saved.

Here's a gist with the details: https://gist.github.com/1717415

It's gotta be something simple that I'm missing...

2

2 Answers

1
votes

OK... found the problem and it's now working.

The first issue was my naming of the columns in the asset model. I had used simple names: i.e., :description, :file_name, :file_size, :content_type. What I needed to use was: :upload_description, :upload_file_name, :upload_file_size, :upload_content_type where the 'upload' (or whatever you want to use) is a prefix that Paperclip will recognize.And of course that changed my Asset model to reference :upload not :asset, as in:

has_attached_file :upload

Secondly (and this post Adding :multipart => true throws Undefined Method "name" error was key to understanding this) was that you cannot specify the full column name (:upload_file_name) in your view, just specify the prefix and Paperclip magically understands what you want.

Hope this helps someone else!

0
votes
  1. Did you install ImageMagick?
  2. Did you added image_magick command_path via initializer?

if not, checkout this answer:

Weird paperclip error message