Today I Learned

hashrocket A Hashrocket project

To Sentence

Check out the Rails to_sentence method, which takes an array and returns a stringified sentence.

pry(main)> %w(one two three).to_sentence
=> "one, two, and three"

Really handy in the view layer. This method also accepts some interesting options like :words_connector and :locale.

See More #rails TILs
Looking for help? Hashrocket has been an industry leader in Ruby on Rails since 2008. Rails is a core skill for each developer at Hashrocket, and we'd love to take a look at your project. Contact us and find out how we can help you.