I have a hash like this:
{"utf8"=>"✓",
"authenticity_token"=>"yYl/Nts0KRktqjR5K7vYXf1jrOyRJmQOtaF7lPMIeZQ=",
"meeting"=>{"name"=>"Robsbaun",
"start_at(3i)"=>"4",
"start_at(2i)"=>"10",
"start_at(1i)"=>"2013",
"start_at(4i)"=>"11",
"start_at(5i)"=>"15",
"end_at(1i)"=>"2013",
"end_at(2i)"=>"10",
"end_at(3i)"=>"4",
"end_at(4i)"=>"19",
"end_at(5i)"=>"15",
"room_id"=>"1",
"user_id"=>"2"},
"commit"=>"Submit"}
And I want to set the same values for both end_at(2i)
and start_at(2i)
and end_at(3i)
and start_at(3i)
.
How can I do that in Ruby 2.0 and Rails 4?
I already tried something like:
meeting_params[":end_at(3i)"] = meeting_params[":start_at(3i)"]
But it doesn't work.
Thanks in advance.
Directly changing the value should work, it's just a hash. Your syntax isn't quite right though. Assuming it comes in as params
:
params['meeting']['end_at(3i)'] = params['meeting']['start_at(3i)']
You're trying to combine symbols and strings - just stick to one or the other.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.