josh/rack-mount — Issue #34: Resetting request parameters
Author: jcarlson
Created: 2011-11-10 01:40:15+00:00
State: open

Maybe this is an issue, maybe it isn't...

In [Rack::Mount::RouteSet#call](https://github.com/josh/rack-mount/blob/master/lib/rack/mount/route_set.rb#L155), the request parameters are restored onto the request object so that the next potential route can be tried.

Now, the `:parameters_key` [passed in by ActionDispatch::Routing::RouteSet](https://github.com/rails/rails/blob/v3.1.1/actionpack/lib/action_dispatch/routing/route_set.rb#L273) is `"action_dispatch.request.path_parameters"`.

However, in `ActionDispatch::Http::Parameters`, the hash returned in a controller by `#params` is [cached](https://github.com/rails/rails/blob/v3.1.1/actionpack/lib/action_dispatch/http/parameters.rb#L8) on the request using the key `"action_dispatch.request.parameters"`.

So, when `Rack::Mount::RouteSet` rolls on to another route to try, the parameters parsed from the previous route are still present. And if the second attempted route is expecting different parameters, it doesn't work.

Should the `"action_dispatch.request.parameters"` key be restored as well as the `"action_dispatch.request.path_parameters"` in `Rack::Mount::RouteSet#call`?