diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index d4ff4b0373286b68bd09a55ce5227d3b7701e8e9..33e2839e6942999bb57600871ff2967e165b2879 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Excise ingrown code from FormOptionsHelper#options_for_select. #5008 [anonymous]
+
* Small fix in routing to allow dynamic routes (broken after [4242]) [Rick]
map.connect '*path', :controller => 'files', :action => 'show'
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index 4c830afb025368f6b4b5deef2a866a21b54ed694..12a5f7f0f1919a00a59984c8baf4afb4b1d83fb6 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -113,7 +113,6 @@ def options_for_select(container, selected = nil)
options_for_select = container.inject([]) do |options, element|
if !element.is_a?(String) and element.respond_to?(:first) and element.respond_to?(:last)
- is_selected = ( (selected.respond_to?(:include?) ? selected.include?(element.last) : element.last == selected) )
is_selected = ( (selected.respond_to?(:include?) && !selected.is_a?(String) ? selected.include?(element.last) : element.last == selected) )
if is_selected
options << ""
@@ -121,7 +120,6 @@ def options_for_select(container, selected = nil)
options << ""
end
else
- is_selected = ( (selected.respond_to?(:include?) ? selected.include?(element) : element == selected) )
is_selected = ( (selected.respond_to?(:include?) && !selected.is_a?(String) ? selected.include?(element) : element == selected) )
options << ((is_selected) ? "" : "")
end
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb
index f468b69c7e5f503bc0a813f52f3b51a033883d4e..ad293417f564237afb3e5c8d01b897d39bfbc251 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionpack/test/template/form_options_helper_test.rb
@@ -103,6 +103,10 @@ def test_array_options_for_string_include_in_other_string_bug_fix
"\n",
options_for_select([ "ruby", "rubyonrails" ], "ruby")
)
+ assert_dom_equal(
+ %(\n\n),
+ options_for_select([ "ruby", "rubyonrails", nil ], "ruby")
+ )
end
def test_hash_options_for_select