Class: RolesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/roles_controller.rb

Instance Method Summary collapse

Instance Method Details

#editObject

GET /roles/1/edit



26
27
# File 'app/controllers/roles_controller.rb', line 26

def edit
end

#indexObject

GET /roles GET /roles.json



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

def index
  @roles = Role.order(:position)

  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @roles }
  end
end

#showObject

GET /roles/1 GET /roles/1.json



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

def show
  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @role }
  end
end

#updateObject

PUT /roles/1 PUT /roles/1.json



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/roles_controller.rb', line 31

def update
  if params[:move]
    move_position(@role, params[:move])
    return
  end

  respond_to do |format|
    if @role.update(role_params)
      format.html { redirect_to @role, notice: t('controller.successfully_updated', model: t('activerecord.models.role')) }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @role.errors, status: :unprocessable_entity }
    end
  end
end