我有以下型号:
has_paper_trail # Track model with paper_trail
has_attached_file :image, :styles => { :medium => "300x300>"},
:path => ":rails_root/public/attachments/:project_id/ressources/:id_:basename_:style.:extension",
:url => ":rails_root/public/attachments/:project_id/ressources/:id_:basename_:style.:extension"
belongs_to :project
# convert :project_id in path to project_:project_id
Paperclip.interpolates :project_id do |attachment, style|
"project_#{attachment.instance.project_id}"
end
它有效,但当我想在我的视图中显示图像时,它找不到图像,我该如何解决?
答案 0 :(得分:0)
替换
解决:url => ":rails_root/public/attachments/:project_id/ressources/:id_:basename_:style.:extension"
通过
:url => "/attachments/:project_id/ressources/:id_:basename_:style.:extension"