maisonarbre_app/app/controllers/admin/registrants_controller.rb
Nicolas Bally 1fa250e0e4 Initial
2011-07-15 12:29:09 +02:00

82 lines
1.2 KiB
Ruby

# -*- encoding : utf-8 -*-
class Admin::RegistrantsController < ApplicationController
before_filter :authenticate_admin!
layout "admin"
navigation :registrants
before_filter :find_registrants
def index
end
def cible
@registrants = Registrant.all
render :layout => false
end
def new
@registrant = Registrant.new
respond_to do |format|
format.js
end
end
def edit
@registrant = Registrant.find(params[:id])
end
def create
@registrant = Registrant.new(params[:registrant])
respond_to do |format|
if @registrant.save
flash[:notice] = "Le lien à été ajouté avec succès."
self.find_registrants
format.js
else
format.html { render :action => "new" }
format.js { render :action => "new" }
end
end
end
def update
@registrant = Registrant.find(params[:id])
respond_to do |format|
if @registrant.update_attributes(params[:registrant])
format.js
else
format.js { render :action => "edit" }
end
end
end
def destroy
@registrant = Registrant.find(params[:id])
@registrant.destroy
respond_to do |format|
format.js
end
end
def find_registrants
@registrants = Registrant.all
end
end