aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_options_helper.rb
diff options
context:
space:
mode:
authorVasiliy Ermolovich <younash@gmail.com>2012-02-20 22:51:05 +0300
committerVasiliy Ermolovich <younash@gmail.com>2012-02-20 23:14:32 +0300
commit421025f18d6462577202cc1ef6bd7cdbb8723ae2 (patch)
treeae9d2aa8ab3d96de06bd865bdaf1de446a7178bb /actionpack/lib/action_view/helpers/form_options_helper.rb
parenteff507f44dea66119799ae51910d5786e21d6c81 (diff)
downloadrails-421025f18d6462577202cc1ef6bd7cdbb8723ae2.tar.gz
rails-421025f18d6462577202cc1ef6bd7cdbb8723ae2.tar.bz2
rails-421025f18d6462577202cc1ef6bd7cdbb8723ae2.zip
refactor grouped_options_for_select
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_options_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index bc03a1cf83..39cd63074b 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -472,16 +472,16 @@ module ActionView
# <b>Note:</b> Only the <tt><optgroup></tt> and <tt><option></tt> tags are returned, so you still have to
# wrap the output in an appropriate <tt><select></tt> tag.
def grouped_options_for_select(grouped_options, selected_key = nil, prompt = nil)
- body = ''
- body << content_tag(:option, prompt, { :value => "" }, true) if prompt
+ body = "".html_safe
+ body.safe_concat content_tag(:option, prompt, :value => "") if prompt
grouped_options = grouped_options.sort if grouped_options.is_a?(Hash)
- grouped_options.each do |group|
- body << content_tag(:optgroup, options_for_select(group[1], selected_key), :label => group[0])
+ grouped_options.each do |label, container|
+ body.safe_concat content_tag(:optgroup, options_for_select(container, selected_key), :label => label)
end
- body.html_safe
+ body
end
# Returns a string of option tags for pretty much any time zone in the