Module: Sunrise::Models::Asset::ClassMethods

Defined in:
lib/sunrise/models/asset.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sunrise/models/asset.rb', line 13

def self.extended(base)
  base.class_eval do
    belongs_to :user
    belongs_to :assetable, :polymorphic => true
    
    before_validation :make_content_type
    before_create :read_dimensions
    
    delegate :url, :original_filename, :content_type, :size, :path, :styles, :to => :data
    alias :filename :original_filename
  end
end

Instance Method Details

#move_to(index, id) ⇒ Object



26
27
28
# File 'lib/sunrise/models/asset.rb', line 26

def move_to(index, id)
  update_all(["sort_order = ?", index], ["id = ?", id.to_i])
end