1

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?

thank_you
  • 11,001
  • 19
  • 101
  • 185

1 Answers1

2

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.

David Hoelzer
  • 15,862
  • 4
  • 48
  • 67
RAJ
  • 9,697
  • 1
  • 33
  • 63
  • Thanks. What if I have options that I want to pass to the `button_to` method? I guess I pass them inside the elements in the block? – thank_you May 10 '16 at 16:13
  • Can you tell me your intention functionality-wise? In `button_to` as well as `link_to` you are redirecting user to '/'. Why this nesting? – RAJ May 10 '16 at 16:20
  • Forget why I have a `link_to` inside a `button_to`. `link_to` could be a `content_tag`. This was a simplified example. – thank_you May 10 '16 at 16:21
  • Updated the answer. Hope it will help you. – RAJ May 10 '16 at 16:26