diff options
author | José Valim <jose.valim@gmail.com> | 2011-12-08 19:52:26 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-12-08 19:53:16 +0100 |
commit | 7280787a53436046e992305a235e66e4fb458e0f (patch) | |
tree | 43dc2c9511e1b159ff055aa9e1cf624c4843f303 /actionpack/lib | |
parent | 3cae753963f4c7b6c676a20c407a56bb8d98712a (diff) | |
download | rails-7280787a53436046e992305a235e66e4fb458e0f.tar.gz rails-7280787a53436046e992305a235e66e4fb458e0f.tar.bz2 rails-7280787a53436046e992305a235e66e4fb458e0f.zip |
Improve cache on route_key lookup.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/polymorphic_routes.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index e989a38d8b..013cf93dbc 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -165,7 +165,7 @@ module ActionDispatch if parent.is_a?(Symbol) || parent.is_a?(String) parent else - ActiveModel::Naming.route_key(parent).singularize + ActiveModel::Naming.singular_route_key(parent) end end else @@ -176,9 +176,11 @@ module ActionDispatch if record.is_a?(Symbol) || record.is_a?(String) route << record elsif record - route << ActiveModel::Naming.route_key(record) - route = [route.join("_").singularize] if inflection == :singular - route << "index" if ActiveModel::Naming.uncountable?(record) && inflection == :plural + if inflection == :singular + route << ActiveModel::Naming.singular_route_key(record) + else + route << ActiveModel::Naming.route_key(record) + end else raise ArgumentError, "Nil location provided. Can't build URI." end |