我正在使用rails 4.1.6和paperclip 4.2,
我的模型如下:
class QcAttachment < ActiveRecord::Base
has_attached_file :attachment,
:url => "/attachments/:id/:style/:basename.:extension",
:path => ":rails_root/public/attachments/:id/:style/:basename.:extension"
end
我在名为attachment_file_name
和attachment_content_type
的数据库表中仅为回形针创建了两列
我有下面的参数:
params=> { "temp_qc_id" => 1001,
qc_attachment => { "temp_qc_id" => 1001, "attachment_file_name" => "temp_file.jpg", "attachment_content_type" => "image/jpg" } }
当我使用QcAttachment.create(qc_attachment)
创建记录时,记录已保存,我有附件对象和值。
我得到attachment.path
= /home/me/projects/temp_project/public/attachments/25/original/temp_file.jpg
和
attachment.url
=
/attachments/25/original/temp_file.jpg
但是,当我浏览public
目录的temp_project
文件夹时,我没有找到其中的attachment
文件夹或任何其他文件夹以及我保存的文件
日志是:
SQL (0.4ms) INSERT INTO `qc_attachments` (`created_at`, `temp_qc_id`, `attachment_content_type`, `attachment_file_name`, `updated_at`) VALUES ('2015-06-08 12:15:07', 10000001, 'image/png', 'temp_file.jpg', '2015-06-08 12:15:07')
(18.1ms) COMMIT
Completed 200 OK in 38ms (Views: 1.2ms | ActiveRecord: 22.8ms)
任何帮助都会得到满足!