Miles Egan
2005-Feb-10 18:24 UTC
possible bug in options_for_select in actionview''s form_options_helper.rb
In form_options_helper.rb, the options_for_select function, line 56: is_selected = ( (selected.respond_to?(:include?) ? selected.include?(element.last) : element.las\ t == selected) ) This does the wrong thing when I pass in a list of [string, string] options and a string selected value. What happens is that it does substring matches instead of whole string matches because String objects do respond to include? More specifically, if I pass a list like this: ["than", "than"], ["bethany", "bethany"] Both items are marked selected in the list since "bethany" includes "than". I''m not sure what the right thing for options_for_select to do is here. It seems like it should test more explicitly for a collection instead of just the include? message. -- miles