Sha256: ce657fd18972d00da5c84ec58811f025755bcba7714f3a4b32875c45609201ee

Contents?: true

Size: 863 Bytes

Versions: 1

Compression:

Stored size: 863 Bytes

Contents

class Authengine::RolesController < ApplicationController
  layout 'authengine/layouts/authengine'

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

  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

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

  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

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
authengine-0.0.2 app/controllers/authengine/roles_controller.rb