doctororange
doctororange

Reputation: 11810

Using Rails' to_sentence method on deeper branches on an array

I want to comma separate users.names using the handy rails to_sentence method.

Of course users.to_sentence isn't right # => #, #, #, # and #

It looks to me like I'll either have to create an array of the names to use this method on, or give up on using the method...

That said, I'm a total noob so you'll probably have some good advice.

Lay it on me.

Thanks

Upvotes: 0

Views: 197

Answers (1)

Simone Carletti
Simone Carletti

Reputation: 176522

Assuming you want to use the User#name method:

users.map(&:name).to_sentence

Upvotes: 3

Related Questions