nex3/haml — Issue #455: Yield in partial loops and eats all memory in production
Author: nazar
Created: 2011-11-10 18:31:29+00:00
State: open

Hi all.

I've got a slightly disturbing bug that's surfaced in production mode only (using rails 3.0.10 and haml 3.1.3 but also occurs all the way back to 3.0.25).

I have a partial:

```ruby
- email.each do |msg|
=message_content_for_link(msg) do |content|
=link_to content, "#/email/#{msg.id}", :id => "message_#{msg.id}", :class => cycle('even', 'odd') + ' view_message'
```

message_content_for_link is a hepler:

```ruby
def message_content_for_link(msg)
content = msg.is_read ? [content_tag(:span, '', :class => 'read')] : [content_tag(:span)]
content << content_tag(:p, h(msg.from), :class => 'from')
content << content_tag(:p, truncate(h(msg.subject)), :class => 'subject')

yield content.join('').html_safe
end
```

The above works fine in development mode. in production

```ruby
ActionView::Template::Error (failed to allocate memory) on the =message_content_for_link(msg) do |content| line
```

In production, the =message_content_for_link line keeps looping until all memory is exhausted.

Any help or clues greatly appreciated.