我尝试使用自定义路径通过paperclip
保存图片,但它不起作用。
图像记录是在数据库中创建的,但在system/web/message_attachments/images/000/000
中没有任何内容。
在我的message_attachment
模型中:
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
在我的rails日志中:
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
答案 0 :(得分:1)
用户:default_url => " /图片/:风格/ missing.png"而不是:指定存储位置路径的路径。您可以查看Example