我有一些按钮,基本上是用CSS覆盖的<li>
s。我想将整个<li>
链接链接到一个Rails操作。
所以我不想这么做:
<li><%= link_to choice, { :action => "update", :id => @id, :response => index }, :remote => true %></li>
我想做这样的事情:
<%= link_to <li>choice</li>, { :action => "update", :id => @id, :response => index }, :remote => true %>
发布于 2011-11-23 06:54:19
使用html_safe
<%= link_to "<li>choice</li>".html_safe, { :action => "update", :id => @id, :response => index }, :remote => true %>
发布于 2011-11-23 07:16:07
使用块
<%= link_to {...} do %>
<li>choice</li>
<% end %>
请注意,rails 3.x使用<%=
,而rails 2.x使用<%
https://stackoverflow.com/questions/8238248
复制