From e89093aeb4b1f544cb54caf54a0374075250cc59 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 11 Apr 2008 12:34:44 -0500 Subject: Fixed that formatted_polymorphic_route should be able to take the :format as part of a single hash or as the option hash (references #8741) --- actionpack/lib/action_controller/polymorphic_routes.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_controller/polymorphic_routes.rb b/actionpack/lib/action_controller/polymorphic_routes.rb index f043d89dae..2cc2ec7723 100644 --- a/actionpack/lib/action_controller/polymorphic_routes.rb +++ b/actionpack/lib/action_controller/polymorphic_routes.rb @@ -73,7 +73,7 @@ module ActionController end record = extract_record(record_or_hash_or_array) - format = (options[:action].to_s == "formatted" and record_or_hash_or_array.pop) + format = extract_format(record_or_hash_or_array, options) namespace = extract_namespace(record_or_hash_or_array) args = case record_or_hash_or_array @@ -152,6 +152,16 @@ module ActionController end end + def extract_format(record_or_hash_or_array, options) + if options[:action].to_s == "formatted" && record_or_hash_or_array.is_a?(Array) + record_or_hash_or_array.pop + elsif options[:format] + options[:format] + else + nil + end + end + def extract_namespace(record_or_hash_or_array) returning "" do |namespace| if record_or_hash_or_array.is_a?(Array) -- cgit v1.2.3