diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 8ffbe8f88a4a6df81eef534c1ba6c5d70173267d..c57e1ec917d8dcd75948803388afe6f4b3e8a687 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fix a bug in Routing where a parameter taken from the path of the current request could not be used as a query parameter for the next. Closes #6752. [Nicholas Seckar] + * Unrescued ActiveRecord::RecordNotFound responds with 404 instead of 500. [Jeremy Kemper] * Improved auto_link to match more valid urls correctly [Tobias Luetke] diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index b0d0dbcf57aea19f4bce35a6143ed69047fcd6b2..8ae1cb06d9d2127ae440c39344b843aef7884e15 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -333,10 +333,10 @@ def write_generation # the query string. (Never use keys from the recalled request when building the # query string.) - method_decl = "def generate(#{args})\npath, hash = generate_raw(options, hash, expire_on)\nappend_query_string(path, hash, extra_keys(hash, expire_on))\nend" + method_decl = "def generate(#{args})\npath, hash = generate_raw(options, hash, expire_on)\nappend_query_string(path, hash, extra_keys(options))\nend" instance_eval method_decl, "generated code (#{__FILE__}:#{__LINE__})" - method_decl = "def generate_extras(#{args})\npath, hash = generate_raw(options, hash, expire_on)\n[path, extra_keys(hash, expire_on)]\nend" + method_decl = "def generate_extras(#{args})\npath, hash = generate_raw(options, hash, expire_on)\n[path, extra_keys(options)]\nend" instance_eval method_decl, "generated code (#{__FILE__}:#{__LINE__})" raw_method end @@ -1224,7 +1224,7 @@ def generate(options, recall = {}, method=:generate) # drop the leading '/' on the controller name options[:controller] = options[:controller][1..-1] if options[:controller] && options[:controller][0] == ?/ merged = recall.merge(options) - + if named_route path = named_route.generate(options, merged, expire_on) raise RoutingError, "#{named_route_name}_url failed to generate from #{options.inspect}, expected: #{named_route.requirements.inspect}, diff: #{named_route.requirements.diff(options).inspect}" if path.nil? diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 9e48b5391d147e75183085d2b3fc936d19c1d1b0..43397dee3516e31cc66677961e57d4ccf5551a68 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -1687,6 +1687,17 @@ def test_action_left_off_when_id_is_recalled ) end + def test_query_params_will_be_shown_when_recalled + set.draw do |map| + map.connect 'show_post/:parameter', :controller => 'post', :action => 'show' + map.connect ':controller/:action/:id' + end + assert_equal '/post/edit?parameter=1', set.generate( + {:action => 'edit', :parameter => 1}, + {:controller => 'post', :action => 'show', :parameter => 1} + ) + end + end class RoutingTest < Test::Unit::TestCase