I am using rails 4.1.6 and paperclip 4.2,
I have model like following:
class QcAttachment < ActiveRecord::Base
has_attached_file :attachment,
:url => "/attachments/:id/:style/:basename.:extension",
:path => ":rails_root/public/attachments/:id/:style/:basename.:extension"
end
I had created only two columns for paperclip in database table named attachment_file_name and attachment_content_type
I got params like following:
params=> { "temp_qc_id" => 1001,
qc_attachment => { "temp_qc_id" => 1001, "attachment_file_name" => "temp_file.jpg", "attachment_content_type" => "image/jpg" } }
When I create record using QcAttachment.create(qc_attachment), the record has been saved and I got attachment object and values.
I get attachment.path = /home/me/projects/temp_project/public/attachments/25/original/temp_file.jpg
and
attachment.url =
/attachments/25/original/temp_file.jpg
But, when I browse the public folder of temp_projectdirectory, I didn't find out the attachment folder in it or any other folder and the file which I saved.
Logs are:
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)
Any help would be appriciated!