Class: Adminpanel::Gallery
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Adminpanel::Gallery
- Includes:
- Base, Galleryzation
- Defined in:
- app/models/adminpanel/gallery.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.display_name ⇒ Object
51 52 53 |
# File 'app/models/adminpanel/gallery.rb', line 51 def self.display_name I18n.t('model.Gallery') end |
.form_attributes ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/adminpanel/gallery.rb', line 40 def self.form_attributes [ { 'file' => { 'type' => 'file_field', 'label' => I18n.t('model.attributes.file'), } } ] end |
.icon ⇒ Object
55 56 57 |
# File 'app/models/adminpanel/gallery.rb', line 55 def self.icon 'picture-o' end |
Instance Method Details
#move_to_better_position ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/adminpanel/gallery.rb', line 12 def move_to_better_position if self.position > 1 conflicting_gallery = Gallery.find_by_position(position - 1) self.update_attribute(:position, self.position - 1) conflicting_gallery.update_attribute( :position, conflicting_gallery.position + 1 ) true else false end end |
#move_to_worst_position ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/adminpanel/gallery.rb', line 25 def move_to_worst_position records = self.class.count if self.position < records conflicting_gallery = Gallery.find_by_position(position + 1) update_attribute(:position, self.position + 1) conflicting_gallery.update_attribute( :position, conflicting_gallery.position - 1 ) true else false end end |
#name ⇒ Object
59 60 61 |
# File 'app/models/adminpanel/gallery.rb', line 59 def name File.basename(file.path) end |