Sha256: 2a24382339a438afc2c87025ae042144eae07756834be0b381665741b440b393

Contents?: true

Size: 1.86 KB

Versions: 3

Compression:

Stored size: 1.86 KB

Contents

# encoding: utf-8

module Gluttonberg
  module Admin
    module AssetLibrary
      class CollectionsController < Gluttonberg::Admin::BaseController
        before_filter :find_collection  , :only => [:delete , :edit  , :show , :update , :destroy]

        def index
          @collections = AssetCollection.all
        end

        def new
          @collection = AssetCollection.new
        end

        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_path
          else
            render :new
          end
        end

        def update
          if @collection.update_attributes(params[:collection])
            flash[:notice] = "The collection was successfully updated."
            redirect_to admin_assets_path
          else
            flash[:error] = "Sorry, The collection could not be updated."
            render :new
          end
        end

         def delete
            display_delete_confirmation(
              :title      => "Delete “#{@collection.name}” asset collection?",
              :url        => admin_collection_path(@collection),
              :return_url => admin_collections_path
            )
          end

        def destroy
          generic_destroy(@collection, {
            :name => "collection",
            :success_path => admin_assets_path,
            :failure_path => admin_assets_path
          })
        end

        private

          def find_collection
            @collection = AssetCollection.where(:id => params[:id]).first
            raise ActiveRecord::RecordNotFound  if @collection.blank?
          end # find_collection

      end # class
    end #asset_library
  end #admin
end #gb

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gluttonberg-core-3.0.2 app/controllers/gluttonberg/admin/asset_library/collections_controller.rb
gluttonberg-core-3.0.1 app/controllers/gluttonberg/admin/asset_library/collections_controller.rb
gluttonberg-core-3.0.0 app/controllers/gluttonberg/admin/asset_library/collections_controller.rb