Class: Arpa::RolesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/arpa/templates/controllers/roles_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /roles



25
26
27
28
29
# File 'lib/generators/arpa/templates/controllers/roles_controller.rb', line 25

def create
  role_creator.create({ role: role_params },
                      success: redirect_to_index(I18n.t('flash.actions.create_role.notice')),
                      fail: render_errors(:new))
end

#editObject

GET /roles/1/edit



20
21
22
# File 'lib/generators/arpa/templates/controllers/roles_controller.rb', line 20

def edit
  all_resources
end

#indexObject

GET /roles



6
7
8
# File 'lib/generators/arpa/templates/controllers/roles_controller.rb', line 6

def index
  @roles = role_finder.all
end

#newObject

GET /roles/new



14
15
16
17
# File 'lib/generators/arpa/templates/controllers/roles_controller.rb', line 14

def new
  @role = Arpa::Entities::Role.new
  all_resources
end

#removeObject

DELETE /roles/1



39
40
41
42
43
# File 'lib/generators/arpa/templates/controllers/roles_controller.rb', line 39

def remove
  role_remover.remove({ role: @role },
                      success: redirect_to_index(I18n.t('flash.actions.remove_role.notice')),
                      fail: redirect_to_index(I18n.t('flash.actions.remove_role.alert')))
end

#showObject

GET /roles/1



11
# File 'lib/generators/arpa/templates/controllers/roles_controller.rb', line 11

def show; end

#updateObject

PATCH/PUT /roles/1



32
33
34
35
36
# File 'lib/generators/arpa/templates/controllers/roles_controller.rb', line 32

def update
  role_updater.update({ role: role_params },
                      success: redirect_to_index(I18n.t('flash.actions.update_role.notice')),
                      fail: render_errors(:edit))
end