嵌套图标和 Rails' link_to 或 button_to 不适用于 SLIM

Nested icons and Rails' link_to or button_to are not working with SLIM

为什么这不起作用?

 # Note the `do` block
 = button_to 'Accept', firefighters_approve_path(entry), class: 'button is-success' do
    i.fa.fa-thumbs-up

undefined method `stringify_keys' for String:0x007fec0bb7bcc8>

为什么这不起作用?

# Note no `do` block
= button_to 'Accept', firefighters_approve_path(entry), class: 'button is-success'
  i.fa.fa-thumbs-up

undefined method `stringify_keys' for String:0x007fec0bc86b40

我想用slim和fontawesome。我在这里错过了什么?

根据documentation,应该是:

= button_to firefighters_approve_path(entry), class: 'button is-success' do
  i.fa.fa-thumbs-up
    |Accept

如果您使用块,第一个参数应该是路径并且块包含名称。

如果您使用 font-awesome-rails gem, you'd be able to use the fa_icon 助手:

= button_to fa_icon("thumbs-up", text: "Accept"), firefighters_approve_path(entry), class: 'button is-success'