accescible_app/app/controllers/admin/studients_controller.rb
Nicolas Bally e4e4463be1 suite
2021-05-15 15:14:41 +02:00

87 lines
1.3 KiB
Ruby

# -*- encoding : utf-8 -*-
class Admin::StudientsController < ApplicationController
before_filter :authenticate_admin!
layout "admin"
#navigation :studients
def new
@studient = Studient.new(:foyer_id => params[:foyer_id])
end
def create
@studient = Studient.new(params[:studient])
@studients = @studient.foyer.studients.order('name ASC')
if @studient.save
flash[:notice] = "L'étudiant à bien été créé."
respond_to do |format|
format.js
end
else
respond_to do |format|
format.js { render :action => :new}
end
end
end
def edit
@studient = Studient.find(params[:id])
end
def update
@studient = Studient.find(params[:id])
if @studient.update_attributes(params[:studient])
flash[:notice] = "L'étudiant à bien été modifié."
respond_to do |format|
format.html { redirect_to(admin_studients_path()) }
format.js
end
else
respond_to do |format|
format.html { render :action => :edit}
format.js { render :action => :edit}
end
end
end
def destroy
@studient = Studient.find(params[:id])
@studient.destroy
flash[:notice] = "L'étudiant à bien été supprimé."
end
def import
end
def import_validation
end
end