1

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...

JESii
  • 4,678
  • 2
  • 39
  • 44

2 Answers2

1

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!

Community
  • 1
  • 1
JESii
  • 4,678
  • 2
  • 39
  • 44
0
  1. Did you install ImageMagick?
  2. Did you added image_magick command_path via initializer?

if not, checkout this answer:

Weird paperclip error message

Community
  • 1
  • 1
fl00r
  • 82,987
  • 33
  • 217
  • 237
  • Thanks. ImageMagick was already installed; I'm not getting the ImageMagick error that's in your link because I'm not processing images, just plain text files. I did, however, try your initializer trick - just in case - but it doesn't solve the problem. – JESii Feb 01 '12 at 18:09
  • Oh, sorry man, I didn't mention it is not about image processing :D. So in your case it is just permissions problem. Change `chmod` on your uploading dir and everything will work – fl00r Feb 01 '12 at 19:09
  • Hmmm... I checked and the permissions are the same as the other directories and the log/ directory. E.g., `drwxr-xr-x 8 jseidel jseidel 4.0K 2012-02-01 20:25 public/` – JESii Feb 02 '12 at 04:28
  • try for experiment to set `chmod -R public 777` – fl00r Feb 02 '12 at 06:40