Class: Gluttonberg::Admin::AssetLibrary::CollectionsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Gluttonberg::Admin::AssetLibrary::CollectionsController
- Defined in:
- app/controllers/gluttonberg/admin/asset_library/collections_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
-
#show ⇒ Object
if u pass filter param then it will bring filtered assets inside collection.
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 41 def create @collection = AssetCollection.new(params[:collection]) @collection.user_id = current_user.id if @collection.save flash[:notice] = "The collection was successfully created." # library home page redirect_to admin_assets_url else render :new end end |
#delete ⇒ Object
63 64 65 66 67 68 69 |
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 63 def delete display_delete_confirmation( :title => "Delete “#{@collection.name}” asset collection?", :url => admin_collection_path(@collection), :return_url => admin_collections_path ) end |
#destroy ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 71 def destroy if @collection.destroy flash[:notice] = "The collection was successfully deleted." redirect_to admin_assets_url else flash[:error] = "There was an error deleting the collection." redirect_to admin_assets_url end end |
#edit ⇒ Object
17 18 |
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 17 def edit end |
#index ⇒ Object
9 10 11 |
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 9 def index @collections = AssetCollection.all end |
#new ⇒ Object
13 14 15 |
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 13 def new @collection = AssetCollection.new end |
#show ⇒ Object
if u pass filter param then it will bring filtered assets inside collection
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 21 def show @category_filter = ( params[:filter].blank? ? "all" : params[:filter] ) opts = { :per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items") , :page => params[:page] } params[:order_type] = (params[:order_type].blank? ? "desc" : params[:order_type]) @assets = @collection.assets if @category_filter != "all" category = AssetCategory.find(:first , :conditions => { :name => @category_filter }) @assets = @assets.where({:asset_type_id => category.asset_type_ids }) unless category.blank? || category.asset_type_ids.blank? end @assets = @assets.paginate( opts ).order(get_order) end |
#update ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 53 def update if @collection.update_attributes(params[:collection]) flash[:notice] = "The collection was successfully updated." redirect_to admin_assets_url else flash[:error] = "Sorry, The collection could not be updated." render :new end end |