Ruby Rails,具有带有自定义模型属性的附加文件路径
我想用一些模型的属性自定义has_attached_文件路径 这是带有附加文件的模型:Ruby Rails,具有带有自定义模型属性的附加文件路径,ruby,paperclip,Ruby,Paperclip,我想用一些模型的属性自定义has_attached_文件路径 这是带有附加文件的模型: class Picture < ActiveRecord::Base belongs_to :with_content, :polymorphic => true has_attached_file :picture, { :styles => { :mobile => ["320x200#", :png], :original => ["1280x1024&
class Picture < ActiveRecord::Base
belongs_to :with_content, :polymorphic => true
has_attached_file :picture, {
:styles => { :mobile => ["320x200#", :png], :original => ["1280x1024>", :jpg] },
:path => ":rails_root/public/:class/:with_content_type/:style_:basename.:extension"
}
}
Paperclip.interpolates :with_content_type do |attachment, style|
"#{attachment.instance.with_content_type}"
end