diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-10 22:08:20 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-10 22:08:20 +0000 |
commit | b81c46e6bd6997bf6637b5086bbb9cbb32664974 (patch) | |
tree | ff0a624cefac65f0f48e72d120383dd10b730c7a /actionpack/lib | |
parent | 41e4173fd6ce8d6302e096e46976bfb79fb8aeb5 (diff) | |
download | rails-b81c46e6bd6997bf6637b5086bbb9cbb32664974.tar.gz rails-b81c46e6bd6997bf6637b5086bbb9cbb32664974.tar.bz2 rails-b81c46e6bd6997bf6637b5086bbb9cbb32664974.zip |
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
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_options_helper.rb | 2 |
1 files changed, 1 insertions, 1 deletions
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 |