Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Url parameters and post parameters are only merged on the first level

#2750

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?

Reported by Jacob Kjeldahl · June 3rd, 2009 @ 12:42 PM

State: stale
Milestone: 3.x
Assigned to: nobody
Importance: none

Activity

  1. Slipp Douglas
    Slipp Douglas

    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).

    November 28th, 2009 @ 09:04 PM

  2. Slipp Douglas
    Slipp Douglas

    Fixed it by doing a deep_merge. Attached as a lib for Rails 2.3.4. I'll format a patch if anyone wants.

    November 28th, 2009 @ 09:48 PM

  3. Slipp Douglas
    Slipp Douglas

    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.

    December 12th, 2009 @ 10:38 PM

  4. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  5. Rohit Arondekar
    Rohit Arondekar
    • 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.

    October 9th, 2010 @ 04:10 AM