class Image < ActiveRecord::Base belongs_to :object, :polymorphic => true acts_as_list :scope => 'object_type = \'#{object_type}\' and object_id = #{object_id}' has_attached_file :image, :styles => { :thumbnail => "150x150" }, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => ":attachment/:id/:style.:extension" def self.order(ids) update_all( ['position = FIND_IN_SET(id, ?)', ids.join(',')], { :id => ids } ) end end