accescible_app/app/controllers/admin/albums_controller.rb
Nicolas Bally d4484275e8 initial
2011-06-25 12:08:06 +02:00

50 lines
798 B
Ruby

# -*- encoding : utf-8 -*-
class Admin::AlbumsController < ApplicationController
load_and_authorize_resource
def index
@albums = Album.all(:order => :name)
end
def new
@album = Album.new()
end
def create
@album = Album.new(params[:album])
@album_create = true
if @album.save
@albums = Album.all(:order => :name)
else
render :action => :new
end
end
def edit
@album = Album.find(params[:id])
end
def update
@album = Album.find(params[:id])
@album_update = true
if @album.update_attributes(params[:album])
@albums = Album.all(:order => :name)
flash[:notice] = "L'album a bien été renomé."
else
render :action => :edit
end
end
def destroy
@album = Album.find(params[:id])
if @album.id != 1
@album.delete
end
end
end