Solved....
I''ve changed
<td><%= optionals.call(user) %></td>
to
<td><%= with_output_buffer {optionals.call(user)}
%></td>
and now it works.... Probably if I knew how to pass params (user) to
capture helper, I could use that instead
On 28 Lut, 21:14, stevo84
<Blaze...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi
> 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.id %>
> <%= user.created_at %>
> <% end %>
>
> where user.id and user.created_at would be that custom last column
> content
>
> 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)) )
> end
>
> and partial
>
> <table>
> <tr>
> <th>Username</th>
> <th>Email</th>
> <th></th>
> </tr>
> <% users.each do |user| %>
> <tr>
> <td><%=h user.nickname %></td>
> <td><%=h user.email %></td>
> <td><%= optionals.call(user) %></td>
> </tr>
> <% end %>
> </table>
>
> ... 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)...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---