【发布时间】:2012-01-17 16:42:43
【问题描述】:
我的路径有问题。在我的模型中,我有以下设置:
class Pdffiles < ActiveRecord::Base
belongs_to :user
has_attached_file :invoice_file,
:path => ":rails_root/public/pdffiles/:user_id/:style/:basename.:extension",
:url => "/pdffiles/:user_id/:style/:basename.:extension",
:storage => :s3,
:bucket => '...',
:s3_credentials => {
:access_key_id => '...',
:secret_access_key => '...'
}
end
在控制器中查看我的操作:
pdf = Prawn::Document.new
pdf.move_down 70
pdf.text("Prawn Rocks")
pdf.render_file('prawn.pdf')
pdf_file = File.open('prawn.pdf')
pdff = Pdffile.new()
pdff.pdffile_file = pdf_file
pdff.user_id = todays_user.id
pdff.save
我的问题是,这个 PDF 文件存储在 S3 服务器上,但位置不好。相反,目录app/public/pdff/id_of_a_user/file_name_of_pdf_file 是保存到的文件
Users/my_name/my_ruby_root_directory/name_of_my_project/public/pdffiles/id_of_a_user/file_name_of_pdf_file.
我不完全确定,如果我使用虾来保存 PDF 文件是否正确,但我认为问题可能出在控制器中,我已经设置了位置,必须保存创建的文件......
我想问你,为了将 PDF 文件保存到 S3 中的正确目录中,我应该进行哪些更改...所有帮助将不胜感激!
谢谢,九月
【问题讨论】:
标签: ruby-on-rails-3 pdf amazon-s3 paperclip prawn