Class: Gallery
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Gallery
- Extended by:
- FriendlyId
- Defined in:
- app/models/gallery.rb
Defined Under Namespace
Classes: Translation
Instance Method Summary collapse
-
#reorder_positions(ids = nil) ⇒ Object
Refaz a ordenação dos uploads.
- #translations_attributes=(attributes) ⇒ Object
Instance Method Details
#reorder_positions(ids = nil) ⇒ Object
Refaz a ordenação dos uploads
47 48 49 50 51 52 53 54 55 |
# File 'app/models/gallery.rb', line 47 def reorder_positions(ids = nil) [] if ids.blank? counter = 1 ActiveRecord::Base.establish_connection ids.each do |id| ActiveRecord::Base.connection.execute("UPDATE galleries_uploads SET position='#{counter}' WHERE gallery_id='#{self.id}' AND upload_id='#{id}';\n") counter += 1 end end |
#translations_attributes=(attributes) ⇒ Object
39 40 41 42 43 44 |
# File 'app/models/gallery.rb', line 39 def translations_attributes=(attributes) new_translations = attributes.values.reduce({}) do |new_values, translation| new_values.merge! translation.delete("locale") => translation end set_translations new_translations end |