Volkan Volkan - 1 month ago 9
HTML Question

How can I wrap the table trs with divs on rails?

view:

<table><%= render(:partial => 'item') %></table>


the partial:
<div><tr><td>foo</td></tr></div>


I'm expecting to see:
<table><div><tr><td>foo</td></tr></div></table>


but I'm seeing:
<div></div>
<table><tr><td>foo</td></tr></table>


why? and how to achieve my expectation?

Answer

Wrapping tds and trs in divs is incorrect. If you want to add some css or mark a particular td for Capybara, you can use the id or class property inside the td. Something like <td id="td_id" class="td_class">.

Comments