Getting one of multiple inputs

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.

Hmm I tried that and it didn't seem to work...

This thread will help you:

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/286f4dbcc6b4c9d0/fbb99b57132e07e9?lnk=st&q=#fbb99b57132e07e9

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.

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]