Say I had many inputs with ids and names in this format: object_#, where # is any number. Each input is inside its own form with its own submit button. How can I make the controller get the @params[object_#]? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Dec 14, 2007, at 4:00 PM, Mike C wrote:> Say I had many inputs with ids and names in this format: object_#, > where # is any number. Each input is inside its own form with its own > submit button. How can I make the controller get the @params > [object_#]?Assuming the # is in a local variable named my_object @params["object_#{my_object}"] Or, if it is a symbol, then perhaps @params["object_#{my_object}".to_sym] Something like that should do it. -- def gw acts_as_n00b writes_at(www.railsdev.ws) end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hmm I tried that and it didn''t seem to work... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
felipekk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-15 06:47 UTC
Re: Getting one of multiple inputs
This thread will help you: http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/286f4dbcc6b4c9d0/fbb99b57132e07e9?lnk=st&q=#fbb99b57132e07e9 On Dec 14, 10:19 pm, Mike C <snib...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hmm I tried that and it didn''t seem to work...--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
>>> Say I had many inputs with ids and names in this format: object_#, >>> where # is any number. Each input is inside its own form with its >>> own >>> submit button. How can I make the controller get the @params >>> [object_#]? >> >> Assuming the # is in a local variable named my_object >> @params["object_#{my_object}"] >> Or, if it is a symbol, then perhaps >> @params["object_#{my_object}".to_sym] >> Something like that should do it.On Dec 14, 2007, at 10:19 PM, Mike C wrote:> Hmm I tried that and it didn''t seem to work...Well, this test code works, so it''s just a tweak needed for your exact names & data types and such. params = Hash.new params.store(''object_1'',''One'') params.store(''object_2'',''Two'') params.store(''object_3'',''Three'') my_object = ''2'' p params["object_#{my_object}"] -- or with symbols -- params = Hash.new params.store(:object_1,''One'') params.store(:object_2,''Two'') params.store(:object_3,''Three'') my_object = ''2'' p params["object_#{my_object}".to_sym] -- def gw acts_as_n00b writes_at(www.railsdev.ws) end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---