aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-08-31 23:43:32 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-09-03 22:59:15 +0200
commit2607def8621c41d5b0bee09e379ae26890b27f7d (patch)
tree62ff6afcf3ac7e4814d378a10506e9308c8548f2
parent6e5aed057f52ba7dc244104c4c9dd0a9415910ae (diff)
downloadrails-2607def8621c41d5b0bee09e379ae26890b27f7d.tar.gz
rails-2607def8621c41d5b0bee09e379ae26890b27f7d.tar.bz2
rails-2607def8621c41d5b0bee09e379ae26890b27f7d.zip
Use new ActiveModel::Naming.route_key in polymorphic_routes
-rw-r--r--actionpack/lib/action_dispatch/routing/polymorphic_routes.rb13
-rw-r--r--actionpack/test/activerecord/polymorphic_routes_test.rb2
2 files changed, 3 insertions, 12 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
index ecc1651dfe..02ba5236ee 100644
--- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
+++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -177,8 +177,7 @@ module ActionDispatch
if parent.is_a?(Symbol) || parent.is_a?(String)
parent
else
- str = ActiveModel::Naming.plural(parent).singularize
- remove_namespace(str, parent)
+ ActiveModel::Naming.route_key(parent).singularize
end
end
end
@@ -186,8 +185,7 @@ module ActionDispatch
if record.is_a?(Symbol) || record.is_a?(String)
route << record
else
- route << ActiveModel::Naming.plural(record)
- remove_namespace(route, record)
+ route << ActiveModel::Naming.route_key(record)
route = [route.join("_").singularize] if inflection == :singular
route << "index" if ActiveModel::Naming.uncountable?(record) && inflection == :plural
end
@@ -197,13 +195,6 @@ module ActionDispatch
action_prefix(options) + route.join("_")
end
- def remove_namespace(string, parent)
- if namespace = parent.class.parents.detect { |n| n.respond_to?(:_railtie) }
- string.sub!(/#{namespace._railtie.railtie_name}_/, '')
- end
- string
- end
-
def extract_record(record_or_hash_or_array)
case record_or_hash_or_array
when Array; record_or_hash_or_array.last
diff --git a/actionpack/test/activerecord/polymorphic_routes_test.rb b/actionpack/test/activerecord/polymorphic_routes_test.rb
index 23c9fb839e..448aaa5eee 100644
--- a/actionpack/test/activerecord/polymorphic_routes_test.rb
+++ b/actionpack/test/activerecord/polymorphic_routes_test.rb
@@ -436,7 +436,7 @@ class PolymorphicRoutesTest < ActionController::TestCase
def with_namespaced_routes(name)
with_routing do |set|
set.draw do
- namespace(name, :shallow_path => nil, :path => nil, :as => nil) do
+ scope(:module => name) do
resources :blogs do
resources :posts
end