button_to 阻止演示者
button_to block in presenter
我在 Presenter 中使用 button_to
。这很好用。但是,如果我创建一个块,我会收到错误
undefined method `stringify_keys'
我想知道是否可以在视图文件之外使用 button_to
块。
# Inside my presenter class
# The line below causes the error
button_to 'Big Button', '/', {} do
link_to('Home', '/', { })
end.html_safe
我该如何解决这个问题?我是不是漏掉了一些很明显的东西?
我不确定为什么要在按钮内部显示 link,但是,您可以试试这个:
button_to '/', { ... } do
'Big Button'
link_to('Home', '/', { ... })
end.html_safe
您不需要将标签作为 button_to
块的第一个参数。
我在 Presenter 中使用 button_to
。这很好用。但是,如果我创建一个块,我会收到错误
undefined method `stringify_keys'
我想知道是否可以在视图文件之外使用 button_to
块。
# Inside my presenter class
# The line below causes the error
button_to 'Big Button', '/', {} do
link_to('Home', '/', { })
end.html_safe
我该如何解决这个问题?我是不是漏掉了一些很明显的东西?
我不确定为什么要在按钮内部显示 link,但是,您可以试试这个:
button_to '/', { ... } do
'Big Button'
link_to('Home', '/', { ... })
end.html_safe
您不需要将标签作为 button_to
块的第一个参数。