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



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

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, :to => :data
    alias :filename :original_filename
  end
end

Instance Method Details

#move_to(index, id) ⇒ Object



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

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