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_#]?
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
Hmm I tried that and it didn’t seem to work…
This thread will help you:
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