Problems with blocks in views

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.

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs