views:

67

answers:

2

I'm sure I saw a while back a rails helper method where .each in the view accepts a separator such as a comma.

So say I want:

- @results.each do |result| 
  = result.title

#to output
result 1, result 2, result 3

TIA

+1  A: 

Not sure what you are refering to, but:

@results.collect { |r| r.title }.join( ',' )

should do what you want.

Noel Walters
Thanks for answer but to_sentence is what I was looking for. Purely pedanticism mind you. :)
mark
I agree. to_sentence is new to me too, so I'm glad I came here.
Noel Walters
+4  A: 

I think

@results.map(&:title).to_sentence

should do the job. See docu.

Tass
Awesome that's the one. Thanks!
mark