Legendary
Legendary

Reputation: 2242

Paperclip dont save image with custom path

I try to save picture through paperclip with custom path, but it doesn't work.

The image record was created in the database, but in system/web/message_attachments/images/000/000 there is nothing.

In my message_attachment model:

has_attached_file :image, styles: { original: ['1920x1920>', :jpg],
                                    medium:   ['640x640>',   :jpg]
}, path: "web/message_attachments/images/:id/:timestamp_to_i.:style.:extension"

Paperclip.interpolates :timestamp_to_i do |attachment, _|
  attachment.instance_read(:updated_at).to_i
end

In my rails log:

Command :: file -b --mime '/var/folders/jv/628j4sf51rxgvr52tqq1mhgh0000gq/T/00656d7de02cbc853a6b31bc26138d2520150805-76566-1n7ihtp.jpg'
Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/jv/628j4sf51rxgvr52tqq1mhgh0000gq/T/30c2024f8e4df03935003d02f161c2af20150805-76566-5s2k5x.jpg[0]' 2>/dev/null
Command :: convert '/var/folders/jv/628j4sf51rxgvr52tqq1mhgh0000gq/T/30c2024f8e4df03935003d02f161c2af20150805-76566-5s2k5x.jpg[0]' -auto-orient -resize "1920x1920>" '/var/folders/jv/628j4sf51rxgvr52tqq1mhgh0000gq/T/2ffbeb355951900901500392a0001abe20150805-76566-g5q9k0.jpg'
Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/jv/628j4sf51rxgvr52tqq1mhgh0000gq/T/0890e9a741bebcf51f3e48d8c19ec49220150805-76566-1yw3t2t.jpg[0]' 2>/dev/null
Command :: convert '/var/folders/jv/628j4sf51rxgvr52tqq1mhgh0000gq/T/0890e9a741bebcf51f3e48d8c19ec49220150805-76566-1yw3t2t.jpg[0]' -auto-orient -resize "640x640>" '/var/folders/jv/628j4sf51rxgvr52tqq1mhgh0000gq/T/b32faf21545a8b32b20d58e5bd912ae120150805-76566-17wzc0l.jpg'
   (0.2ms)  BEGIN
Command :: file -b --mime '/var/folders/jv/628j4sf51rxgvr52tqq1mhgh0000gq/T/00656d7de02cbc853a6b31bc26138d2520150805-76566-1idvdge.jpg'
Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/jv/628j4sf51rxgvr52tqq1mhgh0000gq/T/0890e9a741bebcf51f3e48d8c19ec49220150805-76566-1yw3t2t.jpg[0]' 2>/dev/null
  SQL (0.5ms)  INSERT INTO "message_attachments" ("image_file_name", "image_content_type", "image_file_size", "image_updated_at", "width", "height") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id"  [["image_file_name", "Wallpaper_3.jpg"], ["image_content_type", "image/jpeg"], ["image_file_size", 502036], ["image_updated_at", "2015-08-05 09:04:34.764154"], ["width", 1920], ["height", 1200]]
   (6.2ms)  COMMIT

enter image description here

Upvotes: 2

Views: 139

Answers (1)

Pardeep Saini
Pardeep Saini

Reputation: 2102

User :default_url => "/images/:style/missing.png" instead of :path to specify storage location path. You can check paperclip documentation

Upvotes: 1

Related Questions