# -*- encoding : utf-8 -*- class Admin::VourcherCodesController < ApplicationController before_filter :auth_admin layout "admin" before_filter :find_vourcher_codes def index end def cible @vourcher_codes = VourcherCode.all render :layout => false end def new @vourcher_code = VourcherCode.new() end def edit @vourcher_code = VourcherCode.find(params[:id]) end def show @vourcher_code = VourcherCode.find(params[:id]) end def create @vourcher_code = VourcherCode.new(params.require(:vourcher_code).permit!) if @vourcher_code.save find_vourcher_codes flash[:notice] = "La catégorie à été ajouté avec succès." else render :action => "new" end end def update @vourcher_code = VourcherCode.find(params[:id]) respond_to do |format| if @vourcher_code.update_attributes(params.require(:vourcher_code).permit!) flash[:notice] = "Le menu à été modifié avec succès." if @reorder format.js { render :action => "update" } else format.js { @vourcher_code = VourcherCode.find(@vourcher_code.id) render :action => "update_row" } end end end end def destroy @vourcher_code = VourcherCode.find(params[:id]) @vourcher_code.destroy find_vourcher_codes flash[:notice] = "La catégorie à bien été supprimée." end protected def find_vourcher_codes @vourcher_codes = VourcherCode.where(archived: false) end end