Class: Attachment

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/attachment.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.reorder(new_order) ⇒ Object



10
11
12
13
14
15
# File 'app/models/attachment.rb', line 10

def self.reorder(new_order)
  new_order.each_with_index do |id, index|
    find(id).update_attributes! :position => index+1
  end
  new_order
end

Instance Method Details

#assetObject



21
22
23
# File 'app/models/attachment.rb', line 21

def asset
  attachable if attachable_type == 'Asset'
end

#attached_to_page?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/models/attachment.rb', line 17

def attached_to_page?
  parent_type == 'Page'
end

#uploadsObject



29
30
31
# File 'app/models/attachment.rb', line 29

def uploads
  (self.attachable ||= Asset.new).uploads
end

#uploads=(new_uploads) ⇒ Object



25
26
27
# File 'app/models/attachment.rb', line 25

def uploads=(new_uploads)
  (self.attachable ||= Asset.new).uploads=new_uploads
end