Browse files

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
  • Loading branch information...
1 parent 9fdd453 commit 3f14b1e94ea7ed8c33cf2efa3220a3931b16b189 @dhh dhh committed Sep 3, 2005
Showing with 1 addition and 1 deletion.
  1. +1 −1 actionpack/lib/action_view/helpers/form_options_helper.rb
View
2 actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -109,7 +109,7 @@ def options_for_select(container, selected = nil)
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

0 comments on commit 3f14b1e

Please sign in to comment.