I've been trying to get a dynamic nested form working with ajax in rails 3.
Originally I was following this example project and one of the helpers (add_task_link) looks really good, except that I can't seem to render a partial into a variable. I know that in a controller I can render_to_string, but not from a helper. It looks like in previous versions of rails it must have worked by just assigning the render call to a vari开发者_开发技巧able, but not any more.
Is there a workaround for this? I'm sure it must still be possible.
Thanks
Use the capture method:
<% snippet = capture do %>
<%= render :partial => 'some partial' %>
<% end %>
Later you can use the variable like this:
<%= snippet %>
精彩评论