Forum: Ruby on Rails passing blocks to partials

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
stevo84 (Guest)
on 2009-02-28 22:20
(Received via mailing list)
I've got following problem:

I am attempting to write helper that will display table (stored in
partial) with some custom last column contents.

I would like to call it like

<% parametrized_users_list(@users) do |user|  %>
  <%= %>
<%= user.created_at %>
  <% end %>

where and user.created_at would be that custom last column

What I did was I've created helper

  def parametrized_users_list(users, options = {}, &block)
        concat( render(:partial => 'users/users_list', :locals =>
options.merge(:users => users, :optionals => block)) )

and partial

  <% users.each do |user| %>
     <td><%=h user.nickname %></td>
     <td><%=h %></td>
     <td><%= %></td>
  <% end %>

... but as I render it, it results in a lot of trash - whole table is
rerendered within itself several times etc... What did I do wrong? How
can I store this erb to later render it in partial with correct
context (user in this case)...
stevo84 (Guest)
on 2009-02-28 22:58
(Received via mailing list)

I've changed
     <td><%= %></td>
     <td><%=  with_output_buffer {} %></td>

and now it works.... Probably if I knew how to pass params (user) to
capture helper, I could use that instead
This topic is locked and can not be replied to.