Class: PrivilegesController

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

Instance Method Summary collapse

Instance Method Details

#deleteObject



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

def delete
  redirect_to :action => :list and return false unless params[:id]
  begin
    privilege = ActiveAcl::Privilege.find(params[:id])
    privilege.destroy
    flash[:success] = 'Privilege successfully deleted'
  rescue ActiveRecord::RecordNotFound => e
    flash[:error] = 'Privilege not found'
  end
        
  redirect_to :action => :list and return false
end

#editObject



13
14
15
16
17
18
19
20
21
# File 'app/controllers/privileges_controller.rb', line 13

def edit
  redirect_to :action => :list and return false unless params[:id]
  begin
    @privilege = ActiveAcl::Privilege.find(params[:id])
  rescue ActiveRecord::RecordNotFound => e
    flash[:error] = 'Privilege not found'
    redirect_to :action => :list and return false
  end
end

#indexObject



5
6
7
# File 'app/controllers/privileges_controller.rb', line 5

def index
  redirect_to :action => :list
end

#listObject



9
10
11
# File 'app/controllers/privileges_controller.rb', line 9

def list
  @privileges = ActiveAcl::Privilege.find(:all, :order => 'section ASC, value ASC')
end

#updateObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/privileges_controller.rb', line 23

def update
  redirect_to :action => :list and return false if params['commit'] == 'Cancel'
  
  begin
    @privilege = ActiveAcl::Privilege.find(params[:id].to_i)
  rescue ActiveRecord::RecordNotFound => e
    flash[:error] = 'Privilege not found'
    redirect_to :action => :list and return false
  end
  
  if (@privilege.update_attributes(params[:privilege]))
    flash[:success] = 'Privilege successfully updated'
    redirect_to :action => :list and return false
  else
    flash.now[:error] = 'There was an error updating the Privilege'
    @title = 'Edit Privilege'
    render :action => :edit
  end   
end