If you want the names seperated by comma, try this:

<%=h @posts.map{|p| p.name}.join(', ') %>

On 18 mrt, 17:48, Michael Pavling <pavl...@gmail.com> wrote:
> On 18 March 2010 16:33, Grick Zh <li...@ruby-forum.com> 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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to