Class: Securial::RolesController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- Securial::RolesController
- Defined in:
- app/controllers/securial/roles_controller.rb
Overview
RolesController
Controller for managing roles in the Securial authorization system.
This controller handles role management operations including:
- Creating new roles
- Listing available roles
- Updating role properties
- Deleting roles
All operations require admin authentication and are typically used for setting up and managing the application’s permission structure.
Routes typically mounted at Securial/admins/roles/* in the host application.
Instance Method Summary collapse
-
#create ⇒ void
Creates a new role in the system.
-
#destroy ⇒ void
Deletes an existing role.
-
#index ⇒ void
Lists all roles in the system.
-
#securial_role_params ⇒ ActionController::Parameters
private
Permits and extracts role parameters from the request.
-
#set_securial_role ⇒ void
private
Finds and sets a specific role for show, update and destroy actions.
-
#show ⇒ void
Shows details for a specific role.
-
#update ⇒ void
Updates an existing role.
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ void
This method returns an undefined value.
Creates a new role in the system.
Adds a new role with the provided attributes.
45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/securial/roles_controller.rb', line 45 def create @securial_role = Role.new(securial_role_params) if @securial_role.save render :show, status: :created, location: @securial_role else render json: @securial_role.errors, status: :unprocessable_entity end end |
#destroy ⇒ void
This method returns an undefined value.
Deletes an existing role.
Permanently removes a role from the system.
76 77 78 79 |
# File 'app/controllers/securial/roles_controller.rb', line 76 def destroy @securial_role.destroy head :no_content end |
#index ⇒ void
This method returns an undefined value.
Lists all roles in the system.
Retrieves all roles for administrative display and management.
26 27 28 |
# File 'app/controllers/securial/roles_controller.rb', line 26 def index @securial_roles = Role.all end |
#securial_role_params ⇒ ActionController::Parameters (private)
Permits and extracts role parameters from the request.
95 96 97 |
# File 'app/controllers/securial/roles_controller.rb', line 95 def securial_role_params params.expect(securial_role: [:role_name, :hide_from_profile]) end |
#set_securial_role ⇒ void (private)
This method returns an undefined value.
Finds and sets a specific role for show, update and destroy actions.
87 88 89 |
# File 'app/controllers/securial/roles_controller.rb', line 87 def set_securial_role @securial_role = Role.find(params[:id]) end |
#show ⇒ void
This method returns an undefined value.
Shows details for a specific role.
Retrieves and displays information for a single role.
36 37 |
# File 'app/controllers/securial/roles_controller.rb', line 36 def show end |
#update ⇒ void
This method returns an undefined value.
Updates an existing role.
Modifies the attributes of an existing role.
62 63 64 65 66 67 68 |
# File 'app/controllers/securial/roles_controller.rb', line 62 def update if @securial_role.update(securial_role_params) render :show else render json: @securial_role.errors, status: :unprocessable_entity end end |