aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-06 16:01:26 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-05-12 15:54:44 -0700
commita572a0e75403ed0fefa27a0e602b73e1b6edb478 (patch)
tree5a5b7ebf807cbf3b07f5ce1aebc73cdcbc161a61 /actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
parentb451648e1f611f574ed67f80ca4e9cc600488981 (diff)
downloadrails-a572a0e75403ed0fefa27a0e602b73e1b6edb478.tar.gz
rails-a572a0e75403ed0fefa27a0e602b73e1b6edb478.tar.bz2
rails-a572a0e75403ed0fefa27a0e602b73e1b6edb478.zip
only send options if there are any options
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/polymorphic_routes.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/polymorphic_routes.rb12
1 files 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