Class: Api::RolesController

Inherits:
BaseController show all
Includes:
WithUserParams
Defined in:
app/controllers/api/roles_controller.rb

Direct Known Subclasses

StudentsController, TeachersController

Instance Method Summary collapse

Methods included from WithUserParams

#user_name_params

Methods included from OnBaseOrganizationOnly

#ensure_base_organization!

Methods included from Mumuki::Laboratory::Controllers::CurrentOrganization

#organization_name, #set_current_organization!, #visit_organization!

Methods included from Mumuki::Laboratory::Controllers::DynamicErrors

#bad_record, #blocked_forum, #disabled, #disabled_organization, #forbidden, #gone, #internal_server_error, #not_found, #render_error, #unauthorized, #unprepared_organization

Instance Method Details

#attachObject



16
17
18
19
# File 'app/controllers/api/roles_controller.rb', line 16

def attach
  @user.attach! role, @course
  head :ok
end

#createObject



10
11
12
13
14
# File 'app/controllers/api/roles_controller.rb', line 10

def create
  @user = User.create_if_necessary(user_params)
  @user.attach! role, @course
  render json: @user
end

#detachObject



21
22
23
24
# File 'app/controllers/api/roles_controller.rb', line 21

def detach
  @user.detach! role, @course
  head :ok
end