aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2010-08-19 14:42:14 +0100
committerJosé Valim <jose.valim@gmail.com>2010-08-19 15:05:33 -0300
commit0cc483aa14d79b2d07fdc71dbd935d1af8361d71 (patch)
tree19839927ba72b9b0aacba0fadd91cf3607ac6383 /actionpack
parent2e455429427a4078d2888cc39305f951bdf1e643 (diff)
downloadrails-0cc483aa14d79b2d07fdc71dbd935d1af8361d71.tar.gz
rails-0cc483aa14d79b2d07fdc71dbd935d1af8361d71.tar.bz2
rails-0cc483aa14d79b2d07fdc71dbd935d1af8361d71.zip
Move edit route before show route so that it will have precedence if the :id parameter allows slashes [#5409 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb4
-rw-r--r--actionpack/test/dispatch/routing_test.rb16
2 files changed, 18 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index c6bbfdb441..26ca2ca818 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -586,10 +586,10 @@ module ActionDispatch
end if parent_resource.actions.include?(:new)
member_scope do
+ get :edit if parent_resource.actions.include?(:edit)
get :show if parent_resource.actions.include?(:show)
put :update if parent_resource.actions.include?(:update)
delete :destroy if parent_resource.actions.include?(:destroy)
- get :edit if parent_resource.actions.include?(:edit)
end
end
@@ -616,10 +616,10 @@ module ActionDispatch
end if parent_resource.actions.include?(:new)
member_scope do
+ get :edit if parent_resource.actions.include?(:edit)
get :show if parent_resource.actions.include?(:show)
put :update if parent_resource.actions.include?(:update)
delete :destroy if parent_resource.actions.include?(:destroy)
- get :edit if parent_resource.actions.include?(:edit)
end
end
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 31702cfd33..8a1bacce15 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -413,6 +413,10 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ resources :sections, :id => /.+/ do
+ get :preview, :on => :member
+ end
+
match '/:locale/*file.:format', :to => 'files#show', :file => /path\/to\/existing\/file/
end
end
@@ -1946,6 +1950,18 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
end
end
+ def test_greedy_resource_id_regexp_doesnt_match_edit_and_custom_action
+ with_test_routes do
+ get '/sections/1/edit'
+ assert_equal 'sections#edit', @response.body
+ assert_equal '/sections/1/edit', edit_section_path(:id => '1')
+
+ get '/sections/1/preview'
+ assert_equal 'sections#preview', @response.body
+ assert_equal '/sections/1/preview', preview_section_path(:id => '1')
+ end
+ end
+
private
def with_test_routes
yield