Class: RolesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- RolesController
- Defined in:
- app/controllers/roles_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #findrole ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
20 21 |
# File 'app/controllers/roles_controller.rb', line 20 def edit end |
#findrole ⇒ Object
6 7 8 |
# File 'app/controllers/roles_controller.rb', line 6 def findrole @role=Role.find(params[:id]) end |
#index ⇒ Object
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 |
#new ⇒ Object
16 17 18 |
# File 'app/controllers/roles_controller.rb', line 16 def new @role=Role.new end |
#show ⇒ Object
23 24 |
# File 'app/controllers/roles_controller.rb', line 23 def show end |
#update ⇒ Object
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 |