Problems with blocks in views


#1

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.


#2

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.