Class: Authengine::RolesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @role = Role.new(params[:role])

  if @role.save
    redirect_to authengine_roles_path
  else
    @roles = Role.equal_or_lower_than(current_user.roles)
    render :action => "new"
  end
end

#destroyObject



9
10
11
12
13
14
15
16
17
# File 'app/controllers/authengine/roles_controller.rb', line 9

def destroy
  @role = Role.find(params[:id])
  if @role.destroy # note: model callback applies
    redirect_to authengine_roles_path
  else
    flash[:error] = "Cannot remove a role if users are assigned.<br/>Please reassign or delete users."
    redirect_to authengine_roles_path
  end
end

#indexObject



4
5
6
7
# File 'app/controllers/authengine/roles_controller.rb', line 4

def index
  @all_roles = Role.find(:all, :order =>:name)
  @roles     = Role.equal_or_lower_than(current_user.roles)
end

#newObject



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

def new
  @role  = Role.new
  @roles = Role.equal_or_lower_than(current_user.roles)
end