在Rails link_to标记中添加内容块

时间:2016-05-06 15:27:27

标签: ruby-on-rails-4

我有以下格式的link_to Rails标记:

<%= link_to 'Delete', somePath, 
method: :delete, confirm: "Are you sure you want to delete this?", 
class: "delete" %>

我一直在尝试添加do块来在生成的锚标记中添加一些任意内容块。我尝试了以下,但无济于事:

<%= link_to '<content>Delete' ... %>
# Which yields => <content>Delete in the DOM as a string instead of HTML

<%= link_to 'Delete' ... class: "delete" do %>
    <content>
<% end %>

抛出错误undefined method 'stringify_keys'。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

尝试:

<%= link_to url_path ... class: "delete" do %>
  Delete <content>
<% end %>