jason328 jason328 - 6 months ago 32
Ruby Question

button_to block in presenter

I'm using

button_to
inside the presenter. This works fine. However if I create a block I receive the error

undefined method `stringify_keys'


I'm wondering if it's even possible to use a
button_to
block outside of a view file.

# Inside my presenter class

# The line below causes the error
button_to 'Big Button', '/', {} do
link_to('Home', '/', { })
end.html_safe


How can I fix this? Am I missing something rather obvious?

RAJ RAJ
Answer

I am not sure why you want to show a link inside of a button, but, you can try this:

button_to '/', { ... } do
  'Big Button'
  link_to('Home', '/', { ... })
end.html_safe

You don't need to include a label as a first argument to your button_to block.

Comments