将类添加到 link_to 块
问题描述:
我有以下代码显示删除"链接:
I have a following code which displays a 'delete' link:
<%= link_to :class => 'some_class', :method => :delete, :data => { :confirm => 'Are you sure?' } do
<span>Delete</span>
<% end %>
但由于某种原因,ROR 没有将 some_class
添加到 a
标签.你知道我能做些什么来解决它吗?提前致谢.
But for some reason ROR is not adding some_class
to a
tag. Have you any idea what can i do to fix it ? Thanks in advance.
答
您需要添加 URL 作为第一个参数,然后添加 html 选项,例如:
You need to add the URL as the first parameter, then the html options, e.g.:
<%= link_to resource_path(@resource), :class => 'some_class', :method => :delete, :data => { :confirm => 'Are you sure?' } do
<span>Delete</span>
<% end %>