From 3f14b1e94ea7ed8c33cf2efa3220a3931b16b189 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 3 Sep 2005 21:30:54 +0000 Subject: Updated the options_for_select to deal with the fact that Strings now implement :first git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2126 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/form_options_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/helpers') diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index b17f4284b0..1daa5782de 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -109,7 +109,7 @@ module ActionView container = container.to_a if Hash === container options_for_select = container.inject([]) do |options, element| - if element.respond_to?(:first) && element.respond_to?(:last) + if element.is_a?(Array) || element.is_a?(Range) is_selected = ( (selected.respond_to?(:include?) ? selected.include?(element.last) : element.last == selected) ) is_selected = ( (selected.respond_to?(:include?) && !selected.is_a?(String) ? selected.include?(element.last) : element.last == selected) ) if is_selected -- cgit v1.2.3