Class: Admin::Muck::RolesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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
    output_admin_messages(@role)
  end
end

#destroyObject



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')
    output_admin_messages
  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
          output_admin_messages
        end
      end
    end

  end
end

#editObject



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

#indexObject



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

#newObject



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

#showObject



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

#updateObject



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
    output_admin_messages(@role)
  end
end