diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb index 2c84329178cbd1e451cd451f8c5169a1b679c94c..b7d4434e85e453f9f28f9e756446973c49fbd237 100644 --- a/activesupport/lib/active_support/core_ext/array/conversions.rb +++ b/activesupport/lib/active_support/core_ext/array/conversions.rb @@ -16,7 +16,7 @@ def to_sentence(options = {}) when 0 "" when 1 - self[0] + self[0].to_s when 2 "#{self[0]} #{options[:connector]}#{self[1]}" else diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb index 5831e2a56a2cdc4bee8ca1f94a6f81c6230c6afa..d8ec45b62aac03acaaa64a02266aef9900a8e860 100644 --- a/activesupport/test/core_ext/array_ext_test.rb +++ b/activesupport/test/core_ext/array_ext_test.rb @@ -33,7 +33,6 @@ def test_plain_array_to_sentence assert_equal "one", ['one'].to_sentence assert_equal "one and two", ['one', 'two'].to_sentence assert_equal "one, two, and three", ['one', 'two', 'three'].to_sentence - end def test_to_sentence_with_connector @@ -57,6 +56,9 @@ def test_one_element assert_equal "one", ['one'].to_sentence end + def test_one_non_string_element + assert_equal '1', [1].to_sentence + end end class ArrayExtToSTests < Test::Unit::TestCase