Class: RolesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



26
27
28
29
30
31
32
33
34
# File 'app/controllers/roles_controller.rb', line 26

def create
  @role=Role.new(params[:role])
  if @role.save
     flash[:notice]="角色创建成功"
  else
     flash[:error]="角色创建失败"
  end
  redirect_to :back and return
end

#destroyObject



45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/roles_controller.rb', line 45

def destroy

  #if @role.delete
  params[:role][:enable]=false
  if @role.update_attributes(params[:role])
     flash[:notice]="角色删除成功"
  else
     flash[:error]="角色删除失败"
  end
  redirect_to :back and return
end

#editObject



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

def edit
end

#findroleObject



6
7
8
# File 'app/controllers/roles_controller.rb', line 6

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

#indexObject



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

def index
  @page,@per_page=params[:page],5
  @minum = @page ? @per_page*(@page.to_i-1) : 0
  @roles=Role.paginate :pages=>@page,:per_page=>@per_page
end

#newObject



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

def new
   @role=Role.new
end

#showObject



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

def show
end

#updateObject



36
37
38
39
40
41
42
43
# File 'app/controllers/roles_controller.rb', line 36

def update
  if @role.update_attributes(params[:role])
     flash[:notice]="角色更新成功"
  else
     flash[:error]="角色更新失败"
  end
  redirect_to :back and return
end