Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from

Conversation

franckverrot
Copy link
Contributor

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 2 commits August 15, 2011 10:31
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>.
… subsequent routes. [Closes rails#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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant