Class: Gluttonberg::Gallery
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Gluttonberg::Gallery
- Includes:
- ActionView::Helpers::TextHelper, Content::Publishable, Content::SlugManagement
- Defined in:
- app/models/gluttonberg/gallery.rb
Instance Method Summary collapse
-
#images ⇒ Object
Array of actual assets.
-
#save_collection_images(params, current_user) ⇒ Object
Attach all images of a collection to current gallery.
Methods included from Content::Publishable
#archive, #archive!, #archived?, #clean_published_date, #draft?, #publish, #publish!, #published?, #publishing_status, #set_status, #unpublish, #unpublish!
Methods included from Content::SlugManagement
Instance Method Details
#images ⇒ Object
Array of actual assets
25 26 27 |
# File 'app/models/gluttonberg/gallery.rb', line 25 def images gallery_images.map{|i| i.image } end |
#save_collection_images(params, current_user) ⇒ Object
Attach all images of a collection to current gallery
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/gluttonberg/gallery.rb', line 30 def save_collection_images(params, current_user) unless params[:collection_id].blank? collection = AssetCollection.where(:id => params[:collection_id]).first collection_images = collection.images Gluttonberg::Feed.log(current_user,self, self.title , "add #{pluralize(collection_images.length , 'image')} from collection '#{collection.name}'") max_position = self.gallery_images.length collection_images.each_with_index do |image , index| self.gallery_images.create({ :caption => image.name, :link => image.link, :credits => image.artist_name, :asset_id => image.id, :position => (max_position + index) }) end self.update_attributes(:collection_imported => true) end end |