Class: HrLite::Admin::RolesController
- Inherits:
-
LeadershipController
- Object
- HrLite::ApplicationController
- BaseController
- LeadershipController
- HrLite::Admin::RolesController
- Defined in:
- app/controllers/hr_lite/admin/roles_controller.rb
Overview
Who may do what. Gated on role.manage, which by default only the
money tier holds — the authority to grant yourself payroll is the
authority to read everyone's pay, so it lives with the pay.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/hr_lite/admin/roles_controller.rb', line 18 def create @role = Role.new(role_params) if @role.save @role.replace_grants!(grant_params) redirect_to admin_roles_path, notice: "#{@role.name} created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/hr_lite/admin/roles_controller.rb', line 42 def destroy role = Role.find(params[:id]) if role.destroy redirect_to admin_roles_path, notice: "#{role.name} deleted.", status: :see_other else redirect_to admin_roles_path, alert: role.errors..to_sentence, status: :see_other end end |
#edit ⇒ Object
28 29 30 |
# File 'app/controllers/hr_lite/admin/roles_controller.rb', line 28 def edit @role = Role.find(params[:id]) end |
#index ⇒ Object
10 11 12 |
# File 'app/controllers/hr_lite/admin/roles_controller.rb', line 10 def index @roles = Role.alphabetical.includes(:role_grants, :role_assignments) end |
#new ⇒ Object
14 15 16 |
# File 'app/controllers/hr_lite/admin/roles_controller.rb', line 14 def new @role = Role.new end |
#update ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/hr_lite/admin/roles_controller.rb', line 32 def update @role = Role.find(params[:id]) if @role.update(role_params) @role.replace_grants!(grant_params) redirect_to admin_roles_path, notice: "#{@role.name} updated." else render :edit, status: :unprocessable_entity end end |