Accessing a Hash from the form Params

I have a form that is passing back the following parameters to my
controller

Parameters: {“umpire”=>{“1”=>“Smith”, “2”=>“Jones”, “3”=>""}

In my Controller I would then like to loop through these new values
updating my data like in this sample fragment

for num in(1…3)
@tmpFixture.update_attribute(:player_id , params[“umpire”[num.to_s]
])
end

However I cant seem to get the syntax right for the update_attribute.
It keeps updating to Null.

I guess I am passing the params from the form in an incorrect format.
Any Suggestions?

i think that should be:

for num in(1…3)
@tmpFixture.update_attribute(:player_id , params[:umpire][num.to_s])
end

On Sep 11, 7:19 am, Mike S. [email protected]

use assoc for the attribute you’re updating

for num in(1…3)
@tmpFixture.update_attribute(:player_id => params[:umpire][num.to_s])
end

Thanks Guys:

As you both said the correct way to get at the working code is:
params[:umpire][num.to_s]

the working fragment is

@tmpResult.update_attribute(:player_id , params[:umpire][num.to_s])

Thanks again!

Mike

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs