Module: SortableAttachments::InstanceMethods
- Defined in:
- lib/sortable_attachments.rb
Instance Method Summary collapse
- #attachment_ids_with_position=(attachment_ids) ⇒ Object
- #reset_attachment_positions_by_ids(ids) ⇒ Object
Instance Method Details
#attachment_ids_with_position=(attachment_ids) ⇒ Object
25 26 27 28 |
# File 'lib/sortable_attachments.rb', line 25 def () self.=() () end |
#reset_attachment_positions_by_ids(ids) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/sortable_attachments.rb', line 30 def (ids) return if self.new_record? ids.each_with_index do |id, i| connection.update( "UPDATE `attachment_links` SET `position` = #{i} " + "WHERE `element_id` = #{self.id} AND `element_type` = '#{self.class.base_class}' AND `attachment_id` = #{id}" ) if id.to_i != 0 end end |