Calling `request.params` in routing constraints cannot interfere with subsequent routes. [Closes #2510] #2531

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
1 participant
Contributor

franckverrot commented Aug 15, 2011

As the same request is reused thru all the routing constraints,
accessing a memoized form of params would prevent the router from
redefining it with a new set of parameters (the current route
parameters).

Another solution could be to dup the env here, but I' not sure this is a good idea in terms of memory.

Joe Van Dyk and others added some commits Aug 12, 2011

@franckverrot Joe Van Dyk Demonstrates a routing bug.
When you call 'request.params' in a constraint matcher, subsequent
routes don't have their path attributes set correctly.

In this case, a URL of '/about' would have params[:something] == 'about' in the route
  match ':id'

Adding this constraint and route causes the following test to fail.

  1) Failure:
test_default_params(TestRoutingMapper)
[/Users/joevandyk/projects/rails/actionpack/test/dispatch/routing_test.rb:1475]:
<"home"> expected but was
<nil>.
6eab906
@franckverrot franckverrot Calling `request.params` in routing constraints cannot interfere with…
… subsequent routes. [Closes #2510]

As the same request is reused thru all the routing constraints,
accessing a memoized form of `params` would prevent the router from
redefining it with a new set of parameters (the current route
parameters).
88862a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment