Ruby 回形针与多态关联

Ruby 回形针与多态关联,ruby,ruby-on-rails-3,paperclip,polymorphic-associations,Ruby,Ruby On Rails 3,Paperclip,Polymorphic Associations,我有多个模型,需要与它们相关联的图像,所以我设置了一个多态关联 现在唯一的问题是,如果我为一篇文章创建了一个图像,并且希望它是200x200,这意味着如果我在图像模型中声明了多种样式,那么我将得到一个不一定需要的多种尺寸的图像 有没有一种方法可以声明Post模型应该只保存一种或两种样式,即使声明了5个维度 下面的例子 class Image < ActiveRecord::Base belongs_to :imageable, polymorphic: true attr_accessi

我有多个模型,需要与它们相关联的图像,所以我设置了一个多态关联

现在唯一的问题是,如果我为一篇文章创建了一个图像,并且希望它是200x200,这意味着如果我在图像模型中声明了多种样式,那么我将得到一个不一定需要的多种尺寸的图像

有没有一种方法可以声明Post模型应该只保存一种或两种样式,即使声明了5个维度

下面的例子

class Image < ActiveRecord::Base
belongs_to :imageable, polymorphic: true

attr_accessible :photo
has_attached_file :photo, :styles => { :small_blog => "250x250#", :large_blog => "680x224#", :thumb => "95x95#", :portfolio_square => "300x300#", :portfolio_small => "220x220#", :portfolio_large => "680x680#" },
:storage => :s3,
:url  => ":s3_domain_url",
:s3_protocol => 'http',
:path => "/images/:id/:style.:extension",
:s3_credentials => {
 :bucket => ENV['AWS_BUCKET'],
 :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
 :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
 end


class Post < ActiveRecord::Base

has_many :images, as: :imageable, :dependent => :destroy
accepts_nested_attributes_for :images
attr_accessible :image_id, :images_attributes, :imageable_id, :imageable_attributes


end
如何只保存特定样式?不是所有的。。。以前有人这样做过吗

谢谢