aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-09-28 11:22:16 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-09-28 11:22:16 -0700
commit1ef2b47fb12a94f960b34c4bb1e6ad1f9c900e18 (patch)
treef9b5c0c48c72c11620b78d8278337d7e0a6fce11 /actionpack/lib
parent2fc5c6333b64f01194abd45150c2891f7cc755fe (diff)
downloadrails-1ef2b47fb12a94f960b34c4bb1e6ad1f9c900e18.tar.gz
rails-1ef2b47fb12a94f960b34c4bb1e6ad1f9c900e18.tar.bz2
rails-1ef2b47fb12a94f960b34c4bb1e6ad1f9c900e18.zip
convert inject to map + join
Diffstat (limited to 'actionpack/lib')
-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 43cbba8a0a..83434a9340 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -395,12 +395,12 @@ 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 option_groups_from_collection_for_select(collection, group_method, group_label_method, option_key_method, option_value_method, selected_key = nil)
- collection.inject("") do |options_for_select, group|
+ collection.map do |group|
group_label_string = eval("group.#{group_label_method}")
- options_for_select += "<optgroup label=\"#{html_escape(group_label_string)}\">"
- options_for_select += options_from_collection_for_select(eval("group.#{group_method}"), option_key_method, option_value_method, selected_key)
- options_for_select += '</optgroup>'
- end.html_safe
+ "<optgroup label=\"#{html_escape(group_label_string)}\">" +
+ options_from_collection_for_select(eval("group.#{group_method}"), option_key_method, option_value_method, selected_key) +
+ '</optgroup>'
+ end.join.html_safe
end
# Returns a string of <tt><option></tt> tags, like <tt>options_for_select</tt>, but