Class: Admin::Muck::RolesController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::Muck::RolesController
- Defined in:
- app/controllers/admin/muck/roles_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/controllers/admin/muck/roles_controller.rb', line 19 def create @role = Role.new(params[:role]) if @role.save ajax_update_roles else (@role) end end |
#destroy ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/admin/muck/roles_controller.rb', line 42 def destroy @role = Role.find(params[:id]) if @role.rolename == 'administrator' flash[:notice] = translate('muck.users.cant_delete_administrator_role') else success = @role.destroy flash[:notice] = translate('muck.users.role_not_deleted') if !success respond_to do |format| format.html do flash[:notice] = translate('muck.users.role_deleted') if success redirect_to admin_roles_path end format.xml { head :ok } format.js do if success render :template => 'admin/roles/destroy', :layout => false else end end end end end |
#edit ⇒ Object
28 29 30 31 |
# File 'app/controllers/admin/muck/roles_controller.rb', line 28 def edit @role = Role.find(params[:id]) render :template => 'admin/roles/edit', :layout => false end |
#index ⇒ Object
3 4 5 6 |
# File 'app/controllers/admin/muck/roles_controller.rb', line 3 def index @roles = Role.by_alpha render :template => 'admin/roles/index' end |
#new ⇒ Object
14 15 16 17 |
# File 'app/controllers/admin/muck/roles_controller.rb', line 14 def new @role = Role.new(params[:role]) render :template => 'admin/roles/new', :layout => false end |
#show ⇒ Object
8 9 10 11 12 |
# File 'app/controllers/admin/muck/roles_controller.rb', line 8 def show @role = Role.find(params[:id]) @users = @role.users.paginate(:page => @page, :per_page => @per_page) render :template => 'admin/roles/show' end |
#update ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'app/controllers/admin/muck/roles_controller.rb', line 33 def update @role = Role.find(params[:id]) if @role.update_attributes(params[:role]) ajax_update_roles else (@role) end end |