Class: Securial::RolesController

Inherits:
ApplicationController show all
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

Methods inherited from ApplicationController

#render_400, #render_404

Instance Method Details

#createvoid

This method returns an undefined value.

Creates a new role in the system.

Adds a new role with the provided attributes.

Parameters:

  • params[:securial_role] (Hash)

    Role attributes including role_name and hide_from_profile



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

#destroyvoid

This method returns an undefined value.

Deletes an existing role.

Permanently removes a role from the system.

Parameters:

  • params[:id] (Integer)

    The ID of the role to delete



76
77
78
79
# File 'app/controllers/securial/roles_controller.rb', line 76

def destroy
  @securial_role.destroy
  head :no_content
end

#indexvoid

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_paramsActionController::Parameters (private)

Permits and extracts role parameters from the request.

Returns:

  • (ActionController::Parameters)

    Permitted role parameters



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_rolevoid (private)

This method returns an undefined value.

Finds and sets a specific role for show, update and destroy actions.

Parameters:

  • params[:id] (Integer)

    The ID of the role to find



87
88
89
# File 'app/controllers/securial/roles_controller.rb', line 87

def set_securial_role
  @securial_role = Role.find(params[:id])
end

#showvoid

This method returns an undefined value.

Shows details for a specific role.

Retrieves and displays information for a single role.

Parameters:

  • params[:id] (Integer)

    The ID of the role to display



36
37
# File 'app/controllers/securial/roles_controller.rb', line 36

def show
end

#updatevoid

This method returns an undefined value.

Updates an existing role.

Modifies the attributes of an existing role.

Parameters:

  • params[:id] (Integer)

    The ID of the role to update

  • params[:securial_role] (Hash)

    Updated role attributes



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