4
<%= link_to('Repay', controller: 'payments', 
                             action: 'repay', 
                             from: r, to: rx,
                             html_options: {class: "tiny button"}) 
                             %>

Rails 文档说您可以传递 html_options,它将用于向生成的 html 添加属性,但它所做的只是将 ?html_options={class... 添加到 url,而不是实际生成与类的链接。

我在没有 html_options 的情况下尝试过,同样的事情。不知道我做错了什么。

4

1 回答 1

6

这应该这样做:

<%= link_to('Repay', {controller: 'payments', 
    action: 'repay', 
    from: r, to: rx},
    {class: "tiny button"}) %>
于 2013-07-06T21:50:42.213 回答