78 lines
978 B
Ruby
78 lines
978 B
Ruby
# -*- encoding : utf-8 -*-
|
|
|
|
class Admin::CategoriesController < ApplicationController
|
|
before_filter :auth_admin
|
|
|
|
layout "admin"
|
|
|
|
|
|
before_filter :find_categories
|
|
|
|
|
|
def index
|
|
|
|
end
|
|
|
|
|
|
def cible
|
|
@categories = Category.all
|
|
|
|
render :layout => false
|
|
end
|
|
|
|
|
|
def new
|
|
@category = Category.new
|
|
|
|
end
|
|
|
|
def edit
|
|
@category = Category.find(params[:id])
|
|
end
|
|
|
|
|
|
def create
|
|
@category = Category.new(params[:category])
|
|
|
|
|
|
if @category.save
|
|
self.find_categories
|
|
flash[:notice] = "La catégorie à été ajouté avec succès."
|
|
|
|
|
|
else
|
|
render :action => "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def update
|
|
@category = Category.find(params[:id])
|
|
|
|
if @category.update_attributes(params[:category])
|
|
flash[:notice] = "La catégorie à été modifié avec succès."
|
|
else
|
|
render :action => "edit"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def destroy
|
|
@category = Category.find(params[:id])
|
|
@category.destroy
|
|
|
|
end
|
|
|
|
|
|
protected
|
|
|
|
def find_categories
|
|
@categories = Category.all
|
|
|
|
end
|
|
end
|