Forum: Ruby on Rails Problems with blocks in views

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Db664d3c532df9c2140448cf3845a357?d=identicon&s=25 Regen (Guest)
on 2007-06-13 11:33
Hello,

I have a strange behavior in a view. If I do

    <% @atoms.group_by(&:type).each do |type, atoms| %>
    <p>
        <h3><%= type %></h3>
        <%= render :partial => 'row', :collection => atoms %>
    </p>
    <% end %>

the problem is, first all types are listed and _below_ it all rows in
one block.
Why this happens?


If I do

    <% @atoms.group_by(&:type).each do |type, atoms| %>
    <p>
        <h3><%= type %></h3>
        <%= atoms.map {|atom| atom.name} %>
    </p>
    <% end %>

then it does what i expect: under every type it lists its own atoms.
How to achive this without a block in my view? Something like atoms.map
do |map| doesn't work, I dont know why not.

Thanks for your advice.
Db664d3c532df9c2140448cf3845a357?d=identicon&s=25 Regen (Guest)
on 2007-06-14 16:30
Regen wrote:
> the problem is, first all types are listed and _below_ it all rows in
> one block.
> Why this happens?

Has anyone a clue? Is there a special buffer concept in Rails?

R.
This topic is locked and can not be replied to.