diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-04-30 15:07:57 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-04-30 15:07:57 -0700 |
commit | f1c0358ee752252e4910eeb256d146aeee28ba5d (patch) | |
tree | 041fcb9b4855445ef865f39e768e4b15ac75b16e | |
parent | 6e34d090b2c7b8eb54243feb2b00b08dfc40ffac (diff) | |
download | rails-f1c0358ee752252e4910eeb256d146aeee28ba5d.tar.gz rails-f1c0358ee752252e4910eeb256d146aeee28ba5d.tar.bz2 rails-f1c0358ee752252e4910eeb256d146aeee28ba5d.zip |
eliminate conditional when sending the named route method
-rw-r--r-- | actionpack/lib/action_dispatch/routing/polymorphic_routes.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index 2fb03f2712..37f291a960 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -101,10 +101,12 @@ module ActionDispatch # 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 @@ module ActionDispatch 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 |