Class: Admin::RolesController

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

Instance Method Summary collapse

Instance Method Details

#createObject


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

def create
  @role = Role.new(params[:role])

  respond_to do |format|
    if @role.save
      flash[:notice] = 'Role was successfully created.'
      format.html { redirect_to(@role) }
      format.xml  { render xml: @role, status: :created, location: @role }
    else
      format.html { render action: 'new' }
      format.xml  { render xml: @role.errors, status: :unprocessable_entity }
    end
  end
end

#indexObject


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

def index
  @roles = Role.group(:name).pluck(:name)

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

#newObject


24
25
26
27
28
29
30
31
# File 'app/controllers/admin/roles_controller.rb', line 24

def new
  @role = Role.new

  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render xml: @role }
  end
end

#showObject


15
16
17
18
19
20
21
22
# File 'app/controllers/admin/roles_controller.rb', line 15

def show
  @role = Role.find(params[:id])

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