所以,我使用了paperclip和capistrano。
由于某些原因,这些文件未在/shared/public/system/:class/:attachment/:id_partition/:style/:filename
中上传,而是在/shared/public/system/system/:class/:attachment/:id_partition/:style/:filename
中上传。我不明白为什么。
此外,当我尝试显示图片时,网址为mywebsite.com/system/companies/logos/000/000/015/medium/logo_small.jpg
而不是漂亮的网址。
这是我的模特: company.rb
class Company < ActiveRecord::Base
has_attached_file :logo, :styles => { :medium => "300x300>", :thumb => "100x100>" },
processors: [:compression],
:default_url => "/images/:style/missing.png",
:path => "system/:class/:attachment/:id_partition/:style/:filename",
:url => "system/:class/:attachment/:id_partition/:style/:basename.:extension"
validates_attachment_content_type :logo, :content_type => /\Aimage\/.*\Z/
end
和我的初始化程序: paperclip.rb
Paperclip.options[:command_path] = "/usr/local/bin/"
Paperclip::Attachment.default_options[:storage] = :fog
Paperclip::Attachment.default_options[:fog_credentials] = {:provider => "Local", :local_root => "#{Rails.root}/public/system"}
Paperclip::Attachment.default_options[:fog_directory] = ""
Paperclip::Attachment.default_options[:use_timestamp] = false
答案 0 :(得分:0)
将此更改为,
Paperclip::Attachment.default_options[:fog_credentials] = {:provider => "Local", :local_root => "#{Rails.root}/public"}
您也可以试试这个,我认为没有必要在paperclip.eb文件中传递:local_root
:path => ":Rails.root/public/system/:class/:attachment/:id_partition/:style/:filename"