Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make sure nested singular resources get the correct name

[#3911 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
commit dfc7ff64298e1a0656639a630cc0ddbf93c1eeb9 1 parent aa758b9
@DefV DefV authored jeremy committed
View
5 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -452,7 +452,10 @@ def resource(*resources, &block)
scope(:path => resource.name.to_s, :controller => resource.controller) do
with_scope_level(:resource, resource) do
- yield if block_given?
+
+ scope(:name_prefix => resource.name.to_s) do
+ yield if block_given?
+ end
get :show if resource.actions.include?(:show)
post :create if resource.actions.include?(:create)
View
10 actionpack/test/dispatch/routing_test.rb
@@ -24,6 +24,8 @@ def self.matches?(request)
resource :session do
get :create
+
+ resource :info
end
match 'account/logout' => redirect("/logout"), :as => :logout_redirect
@@ -234,6 +236,14 @@ def test_session_singleton_resource
end
end
+ def test_session_info_nested_singleton_resource
+ with_test_routes do
+ get '/session/info'
+ assert_equal 'infos#show', @response.body
+ assert_equal '/session/info', session_info_path
+ end
+ end
+
def test_redirect_modulo
with_test_routes do
get '/account/modulo/name'
Please sign in to comment.
Something went wrong with that request. Please try again.