47

Is there a standard rails helper that converts an array of strings like ["apple", "banana", "pear"] into "apple, banana, and pear" for inserting into a sentence?

spike
  • 9,794
  • 9
  • 54
  • 85

1 Answers1

95

Yeah to_sentence ought to work nicely.

http://apidock.com/rails/Array/to_sentence

Webjedi
  • 4,677
  • 7
  • 42
  • 59