diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2012-08-04 11:24:53 +0100 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2012-08-04 11:24:53 +0100 |
commit | 6be564c7a087773cb0b51c54396cc190e4f5c983 (patch) | |
tree | 1b3474650e529d52d5051fac256ee7fea736588c /actionpack/lib | |
parent | 61c8a4d926343903593a27080216af7e4ed81268 (diff) | |
download | rails-6be564c7a087773cb0b51c54396cc190e4f5c983.tar.gz rails-6be564c7a087773cb0b51c54396cc190e4f5c983.tar.bz2 rails-6be564c7a087773cb0b51c54396cc190e4f5c983.zip |
Refactor passing url options via array for polymorphic_url
Rather than keep the url options in record_or_hash_or_array, extract it
and reverse merge with options as it may contain important private keys
like `:routing_type`.
Closes #7259
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/polymorphic_routes.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index 7bdd9244d1..93e8418d9c 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -93,6 +93,7 @@ module ActionDispatch def polymorphic_url(record_or_hash_or_array, options = {}) if record_or_hash_or_array.kind_of?(Array) record_or_hash_or_array = record_or_hash_or_array.compact + options.reverse_merge!(record_or_hash_or_array.extract_options!) if record_or_hash_or_array.first.is_a?(ActionDispatch::Routing::RoutesProxy) proxy = record_or_hash_or_array.shift end @@ -165,7 +166,6 @@ module ActionDispatch def build_named_route_call(records, inflection, options = {}) if records.is_a?(Array) - query_string = records.pop if records.last.is_a?(Hash) record = records.pop route = records.map do |parent| if parent.is_a?(Symbol) || parent.is_a?(String) @@ -199,7 +199,7 @@ module ActionDispatch def extract_record(record_or_hash_or_array) case record_or_hash_or_array when Array - record_or_hash_or_array.last.is_a?(Hash) ? record_or_hash_or_array[-2] : record_or_hash_or_array.last + record_or_hash_or_array.last when Hash; record_or_hash_or_array[:id] else record_or_hash_or_array end |