From 4cfa10cda5e5088eabce10cef0623e2b2a9c40dd Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 1 Mar 2015 16:16:03 -0800 Subject: refactor `handle_model` to use private helper methods for generation --- .../lib/action_dispatch/routing/polymorphic_routes.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'actionpack/lib/action_dispatch/routing/polymorphic_routes.rb') 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 -- cgit v1.2.3