This project is archived and is in readonly mode.
Url parameters and post parameters are only merged on the first level
Reported by Jacob Kjeldahl | June 3rd, 2009 @ 12:42 PM | in 3.x
When posting to a controller it is possible to specify parameters encoded in the url as well as posting them in the body.
When accessing params in the controller they are merged together and everything is fine.
Except when you post the following
http://example.com/action?report[name]=report&report[desc]=blah...
and the body goes like
report[data]=123,23423,324,234,2345,43
Then params just contain {:report => {:name => 'report', :desc => 'blahblah}}
and the data field is discarded.
It seems to be Rack::Request#params or ActionController::Request#parameters responsible for merging the parameters and it is done using Hash#merge which will just overwrite the hashes in the params hash instead of merging them.
There are no comments so I am not sure this is done on purpose.
I would like them hashes to merge so I get
{:report => {:name => 'report', :desc => 'blahblah', :data => '123,23423,324,234,2345,43'}}
I am not sure whether this is a good idea or it will get too complicated, but it will make some things easier.
Any thoughts?
Comments and changes to this ticket
-
Slipp Douglas November 28th, 2009 @ 09:04 PM
My thoughts: This is a fairly big bug and should be fixed.
I'll post a patch if I can come up with one (however, I may change my approach form-side instead).
-
Slipp Douglas November 28th, 2009 @ 09:48 PM
Fixed it by doing a deep_merge. Attached as a lib for Rails 2.3.4. I'll format a patch if anyone wants.
-
Slipp Douglas December 12th, 2009 @ 10:38 PM
Note: The "hack" posted seems to still work identically with Rails 2.3.5.
I would post a patch, but I've never done it before and I'm not even sure what branch/tag of Rails to patch against. Regardless, let me know if you want me to figure out a patch or not.
-
Rohit Arondekar October 9th, 2010 @ 04:10 AM
- State changed from new to stale
- Importance changed from to
Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>