ruby - Dynanmically update specific rails attributes -


i have constant hash p_fact_map , array of keys of previous hash product_params[:product_factors]. in p_fact_map values mapped value or array of values attribute names of productfactor table.

p_fact_map = {   :x => %w[something]   :y => %w[something2, something]   :z => %w[something 3, something1]   ...   ... } 

i'm trying update dynamic attribute values doing:

productfactor.v << product_params[:p_id] 

the complete method code:

productfactor::p_fact_map.collect.do |k, v|   puts "value #{v}"   if product_params[:product_factors].include? k      v.each |f|        @coach_recommendation_factor.send(f) << @coach.id    end end 

but doesn't recognize attribute name v , following error:

nomethoderror (undefined method `v' #<class:0x007f95de9b8180>) 

is not possible update value of attribute dynamically or have take different approach reach that?

'v' not method productfactor class. if trying use variable v |k, v| replace productfactor.v productfactor.send(v)


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -