demarches-normaliennes/app/controllers/administrations_controller.rb

35 lines
824 B
Ruby
Raw Normal View History

2016-02-23 16:51:24 +01:00
class AdministrationsController < ApplicationController
include SmartListing::Helper::ControllerExtensions
helper SmartListing::Helper
before_action :authenticate_administration!
def index
2016-04-19 10:41:23 +02:00
@admin = Administrateur.new
2016-02-23 16:51:24 +01:00
@admins = smart_listing_create :admins,
2017-06-12 13:49:51 +02:00
Administrateur.all.order(:email),
partial: "administrations/list",
array: true
2016-02-23 16:51:24 +01:00
end
def create
admin = Administrateur.new create_administrateur_params
if admin.save
flash.notice = "Administrateur créé"
NewAdminMailer.new_admin_email(admin).deliver_now!
2016-02-23 16:51:24 +01:00
else
flash.alert = admin.errors.full_messages.join('<br>').html_safe
end
redirect_to administrations_path
end
private
def create_administrateur_params
params.require(:administrateur).permit(:email, :password)
end
end