Rails has an Array#to_sentence , which will do the same as array.join(', ') , and optionally add "and" to the last element.
puts "Elements are: #{["element 1", "element 2", "element 3"].to_sentence}."
The rest, as you can see, simply unites it.
source share