From b81c46e6bd6997bf6637b5086bbb9cbb32664974 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 10 Nov 2005 22:08:20 +0000 Subject: options_for_select allows any objects which respond_to? :first and :last rather than restricting to Array and Range. Closes #2824. References [2126]. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2977 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') diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index cd2a00254d..a529b71e31 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.is_a?(Array) || element.is_a?(Range) + if !element.is_a?(String) and element.respond_to?(:first) and element.respond_to?(:last) 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