Class: Gluttonberg::Admin::AssetLibrary::CollectionsController

Inherits:
BaseController show all
Defined in:
app/controllers/gluttonberg/admin/asset_library/collections_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 17

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

#deleteObject



39
40
41
42
43
44
45
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 39

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

#destroyObject



47
48
49
50
51
52
53
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 47

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

#indexObject



9
10
11
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 9

def index
  @collections = AssetCollection.all
end

#newObject



13
14
15
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 13

def new
  @collection = AssetCollection.new
end

#updateObject



29
30
31
32
33
34
35
36
37
# File 'app/controllers/gluttonberg/admin/asset_library/collections_controller.rb', line 29

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