Class: Argus::Trail::RolesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Argus::Trail::RolesController
- Defined in:
- app/controllers/argus/trail/roles_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/argus/trail/roles_controller.rb', line 20 def create @role = role_class.new(role_params) (@role) if @role.save @role.(params[:permission_ids], changed_by: current_actor) redirect_to role_path(@role), notice: "Role '#{@role.name}' created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/argus/trail/roles_controller.rb', line 44 def destroy if @role.actors.any? redirect_to roles_path, alert: "Cannot delete role '#{@role.name}' — it is assigned to #{@role.actors.count} record(s)." else @role.destroy redirect_to roles_path, notice: "Role '#{@role.name}' deleted." end end |
#edit ⇒ Object
32 33 |
# File 'app/controllers/argus/trail/roles_controller.rb', line 32 def edit end |
#index ⇒ Object
7 8 9 10 |
# File 'app/controllers/argus/trail/roles_controller.rb', line 7 def index (role_class) @roles = (role_class).includes(:permissions).order(:name) end |
#new ⇒ Object
15 16 17 18 |
# File 'app/controllers/argus/trail/roles_controller.rb', line 15 def new @role = role_class.new (@role) end |
#show ⇒ Object
12 13 |
# File 'app/controllers/argus/trail/roles_controller.rb', line 12 def show end |
#update ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'app/controllers/argus/trail/roles_controller.rb', line 35 def update if @role.update(role_params) @role.(params[:permission_ids], changed_by: current_actor) redirect_to role_path(@role), notice: "Role '#{@role.name}' updated." else render :edit, status: :unprocessable_entity end end |