Or more concisely (because it's fun): <%=h @posts.map(&:name).to_sentence %> which will make it "Tom, Dick, and Harry".
On Mar 18, 12:46 pm, tomkurt <[email protected]> wrote: > If you want the names seperated by comma, try this: > > <%=h @posts.map{|p| p.name}.join(', ') %> > > On 18 mrt, 17:48, Michael Pavling <[email protected]> wrote: > > > > > On 18 March 2010 16:33, Grick Zh <[email protected]> wrote: > > > > <%=h @posts.each {|p| p.name} %> > > > > why this code return serial strings like #<Post:0x3a893e8> ? > > > Because you're outputting the return value of the whole loop, not the > > output of each block. > > If you run that command in your console, you will see it return an > > array of Posts; and that's what you're trying to render. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

