From a572a0e75403ed0fefa27a0e602b73e1b6edb478 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 6 May 2014 16:01:26 -0700 Subject: only send options if there are any options --- actionpack/lib/action_dispatch/routing/polymorphic_routes.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index c3e9dde583..70b1be3197 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -132,10 +132,8 @@ module ActionDispatch record = record_or_hash_or_array end - inflection = lambda { |name| name.singular_route_key } - - if options[:action] == 'new' - elsif record.try(:persisted?) + if options[:action] == 'new' || record.try(:persisted?) + inflection = lambda { |name| name.singular_route_key } else inflection = lambda { |name| name.route_key } end @@ -170,7 +168,11 @@ module ActionDispatch named_route = action_prefix(options) + route.join("_") - recipient.send(named_route, *args, opts) + if opts.empty? + recipient.send(named_route, *args) + else + recipient.send(named_route, *args, opts) + end end # Returns the path component of a URL for the given record. It uses -- cgit v1.2.3