提交 0cc483aa 编写于 作者: A Andrew White 提交者: José Valim

Move edit route before show route so that it will have precedence if the :id...

Move edit route before show route so that it will have precedence if the :id parameter allows slashes [#5409 state:resolved]
Signed-off-by: NJosé Valim <jose.valim@gmail.com>
上级 2e455429
......@@ -586,10 +586,10 @@ def resource(*resources, &block)
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 @@ def resources(*resources, &block)
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
......
......@@ -413,6 +413,10 @@ def self.matches?(request)
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 @@ def test_singleton_resources_are_not_singularized
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册