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

Closed
wants to merge 2 commits into from
View
2 actionpack/lib/action_dispatch/http/parameters.rb
@@ -6,7 +6,7 @@ module Http
module Parameters
# Returns both GET and POST \parameters in a single hash.
def parameters
- @env["action_dispatch.request.parameters"] ||= begin
+ @env["action_dispatch.request.parameters"] = begin
params = request_parameters.merge(query_parameters)
params.merge!(path_parameters)
encode_params(params).with_indifferent_access
View
9 actionpack/test/dispatch/routing_test.rb
@@ -14,6 +14,13 @@ def self.matches?(request)
end
end
+ class RequestLookup
+ def self.matches?(request)
+ request.params
+ return false
+ end
+ end
+
class YoutubeFavoritesRedirector
def self.call(params, request)
"http://www.youtube.com/watch?v=#{params[:youtube_id]}"
@@ -26,6 +33,8 @@ def self.call(params, request)
default_url_options :host => "rubyonrails.org"
resources_path_names :correlation_indexes => "info_about_correlation_indexes"
+ match ':something' => 'foo#something', :constraints => RequestLookup
+
controller :sessions do
get 'login' => :new
post 'login' => :create