0

有没有办法将 link_to 标记和 button_to 标记结合起来,使按钮成为链接..

我需要结合以下两行代码:

        <%= button_to 'Edit', edit_product_path(@product), :type => "submit", :class => "style3", :method => "get" %>

<%= link_to 'Edit', edit_product_path(@product) %>
4

3 回答 3

1

我知道这篇文章有点老了,但我试图做同样的事情,我想通过使用嵌入式 ruby​​(即 <%= something_path %>)和<button>我的 html 中的标签来使用两个名为路由的 Rails。我想出如何做到这一点的唯一方法是向 link_to 添加一个 twitter-bootstrap 按钮类。如果其他人知道如何在不使用 twitter-bootstrap 按钮和使用普通 ol html 按钮的情况下执行此操作,请提供建议,谢谢。

<%= link_to "Add", new_user_path, :class => "btn btn-mini" %>
于 2012-10-09T21:19:11.950 回答
0
# like this?
def link_bu(value, path)    
  "<input type=\"button\" onclick=\"window.location='#{path}';\" value=\"#{value}\"".html_safe
end
于 2012-08-11T10:03:46.700 回答
0

抱歉这个令人困惑的问题......这就是我需要的......

<%= link_to image_tag("/assets/addbutton.png", alt: "Add"),  new_user_path %>
于 2012-08-11T22:24:07.380 回答