我有这段代码可以通过“link_to”函数生成一个“取消关注”按钮:
<%= link_to "Non seguire più", user_user_relationship_path(id:@relationship.id), remote: true, id: "follow_#{@user.id}", class:"btn btn-small btn-danger", method: :delete %>
我想知道如何对所有这些参数使用“do..end”语法。谢谢!
最佳答案
您只需跳过第一个参数,将其余参数包裹在括号中,然后添加 do/end。
<%= link_to(user_user_relationship_path(id:@relationship.id), remote: true, id: "follow_#{@user.id}", class:"btn btn-small btn-danger", method: :delete) do %>
<!-- your button html here -->
<% end %>
关于ruby-on-rails - Rails link_to 语法以添加一些内部 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12187197/