如何在下面的代码中动态传递选项哈希?
class Resource < ActiveRecord::Base
belongs_to :attachable, :polymorphic => true
has_attached_file :attachment #, paperclip_options from attachable
end
class ItemTypeOne < ActiveRecord::Base
has_many :resources, :as => :attachable, :dependent => :destroy
def paperclip_options
ITEM_TYPE_ONE_OPTIONS
end
end
class ItemTypeTwo < ActiveRecord::Base
has_many :resources, :as => :attachable, :dependent => :destroy
def paperclip_options
ITEM_TYPE_TWO_OPTIONS
end
end
我有两个不同的模型(在上面的代码中称为 ItemTypeOne 和 ItemTypeTwo)。这两种型号具有完全不同的回形针存储选项(样式、路径等)