Class: Api::RolesController

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

Direct Known Subclasses

StudentsController, TeachersController

Instance Method Summary collapse

Methods included from OnBaseOrganizationOnly

#ensure_base_organization!

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

#organization_name, #set_current_organization!, #visit_organization!

Methods included from WithAuthorization

#authorization_slug, #authorize_janitor!, #authorize_owner!, #protection_slug

Instance Method Details

#attachObject



14
15
16
17
# File 'app/controllers/api/roles_controller.rb', line 14

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

#createObject



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

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

#detachObject



19
20
21
22
# File 'app/controllers/api/roles_controller.rb', line 19

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