aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-03-01 16:16:03 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2015-03-01 16:16:15 -0800
commit4cfa10cda5e5088eabce10cef0623e2b2a9c40dd (patch)
tree13bcc1c6e17a7aac02c1826d59951e6a33e68fcc /actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
parent95c76a7cf390d5c01207757b7b2487e289c41b3d (diff)
downloadrails-4cfa10cda5e5088eabce10cef0623e2b2a9c40dd.tar.gz
rails-4cfa10cda5e5088eabce10cef0623e2b2a9c40dd.tar.bz2
rails-4cfa10cda5e5088eabce10cef0623e2b2a9c40dd.zip
refactor `handle_model` to use private helper methods for generation
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/polymorphic_routes.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/polymorphic_routes.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
index 1a7944780b..9934f5547a 100644
--- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
+++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -247,14 +247,12 @@ module ActionDispatch
args = []
model = record.to_model
- name = if model.persisted?
- args << model
- model.model_name.singular_route_key
- else
- @key_strategy.call model.model_name
- end
-
- named_route = get_method_for_string name
+ named_route = if model.persisted?
+ args << model
+ get_method_for_string model.model_name.singular_route_key
+ else
+ get_method_for_class model
+ end
[named_route, args]
end