diff --git a/actionpack/lib/action_dispatch/http/parameters.rb b/actionpack/lib/action_dispatch/http/parameters.rb index ff555f93a872cc263ad145af9fda70f0b32f035f..0003dd6bfca6c94024cafd0793af952993bbbf24 100644 --- a/actionpack/lib/action_dispatch/http/parameters.rb +++ b/actionpack/lib/action_dispatch/http/parameters.rb @@ -4,6 +4,8 @@ module ActionDispatch module Http module Parameters + PARAMETERS_KEY = 'action_dispatch.request.path_parameters' + def initialize(env) super @symbolized_path_params = nil @@ -25,7 +27,7 @@ def parameters def path_parameters=(parameters) #:nodoc: @env.delete('action_dispatch.request.parameters') - @env[Routing::RouteSet::PARAMETERS_KEY] = parameters + @env[PARAMETERS_KEY] = parameters end # The same as path_parameters with explicitly symbolized keys. @@ -40,7 +42,7 @@ def symbolized_path_parameters # # See symbolized_path_parameters for symbolized keys. def path_parameters - @env[Routing::RouteSet::PARAMETERS_KEY] ||= {} + @env[PARAMETERS_KEY] ||= {} end private diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 8777a9cd713c7ee339d745cf7567079f9e9a73e2..3ca5abf0fd21717d8c17b56290de2ff8023c48f8 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -19,8 +19,6 @@ class RouteSet #:nodoc: # alias inspect to to_s. alias inspect to_s - PARAMETERS_KEY = 'action_dispatch.request.path_parameters' - class Dispatcher < Routing::Endpoint #:nodoc: def initialize(defaults) @defaults = defaults diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index b22bc2dc25957c258e91be960fe78c330f19674f..9dc6d77012c5b3af0eb7b2ae83e342c854e76127 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -87,7 +87,7 @@ def setup def test_symbols_with_dashes rs.draw do get '/:artist/:song-omg', :to => lambda { |env| - resp = ActiveSupport::JSON.encode env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY] + resp = ActiveSupport::JSON.encode ActionDispatch::Request.new(env).path_parameters [200, {}, [resp]] } end @@ -99,7 +99,7 @@ def test_symbols_with_dashes def test_id_with_dash rs.draw do get '/journey/:id', :to => lambda { |env| - resp = ActiveSupport::JSON.encode env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY] + resp = ActiveSupport::JSON.encode ActionDispatch::Request.new(env).path_parameters [200, {}, [resp]] } end @@ -111,7 +111,7 @@ def test_id_with_dash def test_dash_with_custom_regexp rs.draw do get '/:artist/:song-omg', :constraints => { :song => /\d+/ }, :to => lambda { |env| - resp = ActiveSupport::JSON.encode env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY] + resp = ActiveSupport::JSON.encode ActionDispatch::Request.new(env).path_parameters [200, {}, [resp]] } end @@ -124,7 +124,7 @@ def test_dash_with_custom_regexp def test_pre_dash rs.draw do get '/:artist/omg-:song', :to => lambda { |env| - resp = ActiveSupport::JSON.encode env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY] + resp = ActiveSupport::JSON.encode ActionDispatch::Request.new(env).path_parameters [200, {}, [resp]] } end @@ -136,7 +136,7 @@ def test_pre_dash def test_pre_dash_with_custom_regexp rs.draw do get '/:artist/omg-:song', :constraints => { :song => /\d+/ }, :to => lambda { |env| - resp = ActiveSupport::JSON.encode env[ActionDispatch::Routing::RouteSet::PARAMETERS_KEY] + resp = ActiveSupport::JSON.encode ActionDispatch::Request.new(env).path_parameters [200, {}, [resp]] } end