Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

eliminate conditional when sending the named route method

  • Loading branch information...
commit f1c0358ee752252e4910eeb256d146aeee28ba5d 1 parent 6e34d09
@tenderlove tenderlove authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
View
6 actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -101,10 +101,12 @@ module PolymorphicRoutes
# polymorphic_url(Comment) # same as comments_url()
#
def polymorphic_url(record_or_hash_or_array, options = {})
+ recipient = self
+
if record_or_hash_or_array.kind_of?(Array)
record_or_hash_or_array = record_or_hash_or_array.compact
if record_or_hash_or_array.first.is_a?(ActionDispatch::Routing::RoutesProxy)
- proxy = record_or_hash_or_array.shift
+ recipient = record_or_hash_or_array.shift
end
record_or_hash_or_array = record_or_hash_or_array[0] if record_or_hash_or_array.size == 1
end
@@ -139,7 +141,7 @@ def polymorphic_url(record_or_hash_or_array, options = {})
args.collect! { |a| convert_to_model(a) }
- (proxy || self).send(named_route, *args)
+ recipient.send(named_route, *args)
end
# Returns the path component of a URL for the given record. It uses
Please sign in to comment.
Something went wrong with that request. Please try again.