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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
use assoc for the attribute you''re updating for num in(1..3) @tmpFixture.update_attribute(:player_id => params[:umpire][num.to_s]) end On Sep 11, 10:10 am, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > 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? > > -- > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---