lockaz_app/app/controllers/admin/admins_controller.rb
Nicolas Bally f20fe482c6 initial
2020-04-06 10:38:07 +02:00

78 lines
1.0 KiB
Ruby

class Admin::AdminsController < ApplicationController
layout "admin"
before_action :auth_admin
#before_action :has_permission
before_action -> { has_permission?("admins-crud") }
before_action :admin_space
def admin_space
@admin_space = "preferences"
end
def index
@admins = Admin.all
end
def show
@admin = Admin.find(params[:id])
end
def new
@admin = Admin.new
end
def edit
@admin = Admin.find(params[:id])
end
def create
@admin = Admin.new(admin_params)
if @admin.save
@admins = Admin.all
else
render :action => "new"
end
end
def update
@admin = Admin.find(params[:id])
if @admin.update_attributes(admin_params)
else
render :action => "edit"
end
end
def destroy
@admin = Admin.find(params[:id])
@admin.destroy if @admin != @current_admin
end
private
def admin_params
params.require(:admin).permit!
end
end