Skip to content

Commit 1ef2b47

Browse files
committed
convert inject to map + join
1 parent 2fc5c63 commit 1ef2b47

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

actionpack/lib/action_view/helpers/form_options_helper.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,12 @@ def options_from_collection_for_select(collection, value_method, text_method, se
395395
# <b>Note:</b> Only the <tt><optgroup></tt> and <tt><option></tt> tags are returned, so you still have to
396396
# wrap the output in an appropriate <tt><select></tt> tag.
397397
def option_groups_from_collection_for_select(collection, group_method, group_label_method, option_key_method, option_value_method, selected_key = nil)
398-
collection.inject("") do |options_for_select, group|
398+
collection.map do |group|
399399
group_label_string = eval("group.#{group_label_method}")
400-
options_for_select += "<optgroup label=\"#{html_escape(group_label_string)}\">"
401-
options_for_select += options_from_collection_for_select(eval("group.#{group_method}"), option_key_method, option_value_method, selected_key)
402-
options_for_select += '</optgroup>'
403-
end.html_safe
400+
"<optgroup label=\"#{html_escape(group_label_string)}\">" +
401+
options_from_collection_for_select(eval("group.#{group_method}"), option_key_method, option_value_method, selected_key) +
402+
'</optgroup>'
403+
end.join.html_safe
404404
end
405405

406406
# Returns a string of <tt><option></tt> tags, like <tt>options_for_select</tt>, but

0 commit comments

Comments
 (0)