Class: Cats::Core::RolesController

Inherits:
ApplicationController show all
Includes:
Common
Defined in:
app/controllers/cats/core/roles_controller.rb

Instance Method Summary collapse

Methods included from Common

#create, #show, #update

Methods inherited from ApplicationController

#authenticate, #current_user, #skip_bullet

Instance Method Details

#indexObject



8
9
10
11
12
13
# File 'app/controllers/cats/core/roles_controller.rb', line 8

def index
  super do
    Role.joins(:application_module)
        .where(cats_core_application_modules: {prefix: params[:prefix]})
  end
end

#unassigned_rolesObject



15
16
17
18
19
20
# File 'app/controllers/cats/core/roles_controller.rb', line 15

def unassigned_roles
  user = User.find(params[:id])
  roles = Role.where(application_module_id: user.application_module_id)
  unassigned = roles - user.roles
  render json: {success: true, data: serialize(unassigned)}
end

#usersObject



22
23
24
# File 'app/controllers/cats/core/roles_controller.rb', line 22

def users
  render json: {success: true, data: serialize(@role.users)}
end