Module: AutoAssigner::ParamsLoader::ActionController

Defined in:
lib/auto_assigner/params_loader/action_controller.rb

Instance Method Summary collapse

Instance Method Details

#load_params(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/auto_assigner/params_loader/action_controller.rb', line 4

def load_params(params)
  params_hash = params.permit!.to_h
  targets = params_hash.keys.select { |key| key.include?('_id') }
  return if targets.blank?
  
  targets.each do |target|
    hash = params_hash.each_pair { |key, value| puts "key: #{key}, value :#{value}" }
    key, val = hash.assoc(target.dup)
    key.slice!('_id')
    key.camelcase.constantize.find(val)
  end
end