Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby Rails,具有带有自定义模型属性的附加文件路径_Ruby_Paperclip - Fatal编程技术网

Ruby Rails,具有带有自定义模型属性的附加文件路径

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&

我想用一些模型的属性自定义has_attached_文件路径

这是带有附加文件的模型:

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