kaushalpranav
kaushalpranav

Reputation: 2174

Paperclip issues in Rails

I installed paperclip for my rails project and completed the coding part to use it by following a tutorial. But when I used to see the schema of the Item (which contains image as a column), it created four other columns like image_file_name and assigned them respective datatypes. But the column named image did not have any datatype associated with it and remained empty. Where did I miss something. Also I wish to know how the images are stored internally inside paperclip (ex : as strings).

Upvotes: 1

Views: 54

Answers (1)

smooshy
smooshy

Reputation: 66

The paperclip migration creates those 4 fields for internal use:

t.string   "image_file_name"
t.string   "image_content_type"
t.integer  "image_file_size"
t.datetime "image_updated_at"

If you're curious about where the file was saved, you can try opening a rails console and accessing the url property of the uploaded image. I don't know what the name of the model is that you added the attachment to, but let's say you called it UploadedImage and your image attachment is declared like has_attached_file image:

$ rails c
irb> UploadedImage.last.url

This should print out the path for where the image is stored.

There's a section in the paperclip readme that talks about storage: https://github.com/thoughtbot/paperclip#understanding-storage

By default, the location is :rails_root/public/system/:class/:attachment/:id_partition/:style/:filename

Upvotes: 1

Related Questions