Paperclip不会在本地计算机中保存文件

时间:2015-06-08 11:50:59

标签: ruby-on-rails ruby ruby-on-rails-4 paperclip ruby-on-rails-plugins

我正在使用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_nameattachment_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)

任何帮助都会得到满足!

0 个答案:

没有答案