Skip to content
Browse files

Use new ActiveModel::Naming.route_key in polymorphic_routes

  • Loading branch information...
1 parent 6e5aed0 commit 2607def8621c41d5b0bee09e379ae26890b27f7d @drogus drogus committed Aug 31, 2010
View
13 actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -177,17 +177,15 @@ def build_named_route_call(records, inflection, options = {})
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
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 @@ def build_named_route_call(records, inflection, options = {})
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
View
2 actionpack/test/activerecord/polymorphic_routes_test.rb
@@ -436,7 +436,7 @@ def test_uncountable_resource
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

0 comments on commit 2607def

Please sign in to comment.
Something went wrong with that request. Please try again.