aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_dispatch/routing/polymorphic_routes.rb2
-rw-r--r--actionview/test/activerecord/polymorphic_routes_test.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
index 6afd745fe2..36db278eab 100644
--- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
+++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -194,7 +194,7 @@ module ActionDispatch
def build_named_route_call(records, record, inflection, options)
if records.is_a?(Array)
- record = records.pop
+ records.pop
route = records.map { |parent| build_route_part parent, :singular }
else
route = []
diff --git a/actionview/test/activerecord/polymorphic_routes_test.rb b/actionview/test/activerecord/polymorphic_routes_test.rb
index bcdb4f4376..eff6430e8a 100644
--- a/actionview/test/activerecord/polymorphic_routes_test.rb
+++ b/actionview/test/activerecord/polymorphic_routes_test.rb
@@ -131,6 +131,14 @@ class PolymorphicRoutesTest < ActionController::TestCase
end
end
+ def test_namespaced_model_with_name_the_same_as_namespace_omg
+ with_namespaced_routes(:blog) do
+ @blog_blog.save
+ @blog_post.save
+ assert_equal "http://example.com/blogs/#{@blog_blog.id}/posts/#{@blog_post.id}", polymorphic_url([@blog_blog, @blog_post])
+ end
+ end
+
def test_namespaced_model_with_nested_resources
with_namespaced_routes(:blog) do
@blog_post.save