# Problems with blocks in views

**URL:** <https://www.ruby-forum.com/t/problems-with-blocks-in-views/106694>\
**Category:** Rails\
**Created:** [June 13, 2007, 11:33am UTC](https://www.ruby-forum.com/t/problems-with-blocks-in-views/106694 "2007-06-13T11:33:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Regen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/779978/32.png) [@Regen](https://www.ruby-forum.com/u/Regen)\
**Post date:** [June 13, 2007, 11:33am UTC](https://www.ruby-forum.com/t/problems-with-blocks-in-views/106694/1 "2007-06-13T11:33:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Regen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/779978/32.png) [@Regen](https://www.ruby-forum.com/u/Regen)\
**Post date:** [June 14, 2007, 4:30pm UTC](https://www.ruby-forum.com/t/problems-with-blocks-in-views/106694/2 "2007-06-14T16:30:15Z")

</div>

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.
