diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-10-25 17:44:17 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-10-25 17:44:17 -0700 |
commit | 450257c95b0ca2c61eca2cefbcb2afd69e90f4a9 (patch) | |
tree | eb4d65a1d3f6a02fd277fa4f78cee31f7d2d19fe /actionpack/lib | |
parent | 1d9ab88ee6360f54197ce21624d844425ec627b3 (diff) | |
download | rails-450257c95b0ca2c61eca2cefbcb2afd69e90f4a9.tar.gz rails-450257c95b0ca2c61eca2cefbcb2afd69e90f4a9.tar.bz2 rails-450257c95b0ca2c61eca2cefbcb2afd69e90f4a9.zip |
properly handle lists of lists. Thanks @adrianpike for reporting!
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_options_helper.rb | 7 |
1 files changed, 6 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 d636702111..1a6c3b9740 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -579,7 +579,12 @@ module ActionView def to_select_tag(choices, options, html_options) selected_value = options.has_key?(:selected) ? options[:selected] : value(object) - if !choices.empty? && Array === choices.first + # Grouped choices look like this: + # + # [nil, []] + # { nil => [] } + # + if !choices.empty? && choices.first.last.respond_to?(:each) option_tags = grouped_options_for_select(choices, :selected => selected_value, :disabled => options[:disabled]) else option_tags = options_for_select(choices, :selected => selected_value, :disabled => options[:disabled]) |