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:
- @re开发者_开发百科sults.each do |result|
= result.title
#to output
result 1, result 2, result 3
TIA
I think
@results.map(&:title).to_sentence
should do the job. See docu.
Not sure what you are refering to, but:
@results.collect { |r| r.title }.join( ',' )
should do what you want.
精彩评论