Forum: Ruby on Rails replace_html problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7db3b1680807d393d40260591b4ae5e0?d=identicon&s=25 sa 125 (sa125)
on 2008-12-31 14:34
Hi - trying to update a table with page.replace_html using a partial:

The view (index.html.erb):
[code=]<div id='prod_table'>
  <%= render :partial => 'product' %>
</div>[/code]
The partial (_product.html.erb)
[code=]<table>
<% for product in @products %>
 <tr>
  <td><%= product.name %></td>
  <td><%= product.vendor.name %></td>
 </tr>
<% end %>
</table>[/code]
The actual update:
[code=]render :update do |page|
  page.replace_html 'prod_table', :partial => 'product'
end[/code]
I'm getting most of the page back, but the table is messed up, showing
with a lot of \n\n characters (the javascript just shows up on the
screen):
try { Element.update("prod_table", "
\n\n
\n  \nProduct 1   \nVendor 1\n
\n  \nProduct 2   \nVendor 2\n
\n  \nProduct 3   \nVendor 3\n
..
\n\n
"); } catch(e){ alert('RJS error:\n\n' + e.toString());
alert('Element.update(\"prod_table\",\"
\\n
\\n\\n
... and then the whole table again as a long string (it renders the
error message on the screen.

What could be the problem?
This topic is locked and can not be replied to.