rubyonrailsin

A Ruby and Rails talk

Thursday, March 18, 2010


Re: [Rails] Problem about "each" in rails

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

On 18 March 2010 16:33, Grick Zh <lists@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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive