Class: AbilitiesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/abilities_controller.rb

Instance Method Summary collapse

Methods included from SessionsHelper

#preferences_customer_type=, #preferences_customer_type?, #signed_in?, #signed_in_user, #store_location

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/abilities_controller.rb', line 10

def create
  preload
  
  abilities = []
  
  params[:module].each do |mdl_id, abilities_arr|
    mdl = SystemModule.find(mdl_id)
    abilities_arr.each do |ab_id,ab_id2|
      ab = SystemAbility.find(ab_id)
      abilities << { :module => mdl, :ability => ab }
    end
  end
  
  @user.define_abilities abilities
  @user.save
  
  authorize! :create, @user_abilities
  render "index"
end

#indexObject



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

def index
  preload
  authorize! :index, @user_abilities
end

#preloadObject



30
31
32
33
34
35
# File 'app/controllers/abilities_controller.rb', line 30

def preload
  @user = User.find params[:user_id]
  @user_abilities = @user.abilities
  @modules = SystemModule.all
  @abilities = SystemAbility.all
end