Skip to content
Browse files

only send options if there are any options

  • Loading branch information...
1 parent b451648 commit a572a0e75403ed0fefa27a0e602b73e1b6edb478 @tenderlove tenderlove committed May 6, 2014
Showing with 7 additions and 5 deletions.
  1. +7 −5 actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
View
12 actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -132,10 +132,8 @@ def polymorphic_url(record_or_hash_or_array, options = {})
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 @@ def polymorphic_url(record_or_hash_or_array, options = {})
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

0 comments on commit a572a0e

Please sign in to comment.
Something went wrong with that request. Please try again.