我有一个rails 4.2应用程序。我希望整个tr
都是可点击的,并将用户带到用户的产品展示页面。rails links_to帮手html块
目前的HTML呈现没有<href..
,我不完全明白为什么。我错过了什么?
index.html.erb
<div class="panel panel-default">
<table class="table">
<tbody class="product-profile-index">
<%= render @products %>
</tbody>
</table>
</div>
_product.html.erb(部分为索引页)
<%= link_to product do %>
<tr class = "product-index-row">
<td class="col-md-3 name">
<span class="product-image">
<%= image_tag attachment_url(product, :product_image, :fill, 45, 45) %>
</span>
<span class="product-name">
<%= product.name %>
</span>
</td>
<td class="col-md-6 oneliner">
<%= product.oneliner %>
</td>
<td class="col-md-3 updated">
<%= local_time_ago(product.updated_at) %>
</td>
</tr>
<% end %>
css.scss
.product-profile-index {
.product-index-row {
&:hover {
background-color: $gray-medium-light;
}
}
}
UPDATE:
如果我只包裹ht的一小部分毫升这样的,那么它的工作:
<%=link_to product %>
<%= product.name%>
<% end %>
你可以添加'<%= product_path(@product)%>'某处在页面上,让我们知道什么是输出? – jeffdill2
它工作。我曾经用'<%= link_to product%><%= product.name%><% end %>'来使用它,并且运行良好。 (我只是把实例变量放在我的问题中,以便于阅读,但这不是问题) –
非常好。你可以添加它,所以我们可以看到它吗? – jeffdill2