次のように、オブジェクトごとに2行のテーブルにいくつかのオブジェクトを印刷したい:
<tr class="title">
<td>Name</td><td>Price</td>
</tr>
<tr class="content">
<td>Content</td><td>123</td>
</tr>
この質問products_helper.rb
の答えに基づいて、ヘルパーメソッドを に書きました。
def write_products(products)
products.map {
|product|
content_tag :tr, :class => "title" do
content_tag :td do
link_to h(product.name), product, :title=>product.name
end
content_tag :td do
product.price
end
end
content_tag :tr, :class => "content" do
content_tag :td, h(product.content)
content_tag :td, product.count
end
}.join
end
しかし、これは期待どおりには機能しません。最後のノードのみを返します-最後の<td>123</td>
機能させるにはどうすればよいですか?