如何在指定'方法时使用带有link_to的自定义html:'

时间:2017-11-27 08:48:46

标签: html ruby-on-rails ruby

我正在尝试渲染以下html:

<a href="<%= INSERT ARTICLE PATH WITH DELETE METHOD HERE %>" class="float-right action-button">
  <button type="button" class="btn btn-light">
    <%= image_tag("delete", size: "16x16") %>
  </button>
</a>

我试过这个没有成功:

<%= link_to(@article, method: :delete, class: "float-right action-button") do %>
  <button type="button" class="btn btn-light">
    <%= image_tag("delete", size: "16x16") %>
  </button>
<%= end %>

我收到以下错误:

SyntaxError in ArticlesController#index
C:/Sites/anais-coaching/app/views/articles/index.html.erb:34: syntax error, unexpected keyword_end ...eze;@output_buffer.append=( end );@output_buffer.safe_append... ... ^ C:/Sites/anais-coaching/app/views/articles/index.html.erb:43: syntax error, unexpected keyword_end, expecting ')' '.freeze; end ^ C:/Sites/anais-coaching/app/views/articles/index.html.erb:47: syntax error, unexpected keyword_ensure, expecting ')' C:/Sites/anais-coaching/app/views/articles/index.html.erb:49: syntax error, unexpected keyword_end, expecting ')'

我认为我的问题是我不知道如何使用&#39; link_to xxx do&#39;。 谢谢!

0 个答案:

没有答案