Home > OS >  Combining button_to with a path helper and a class
Combining button_to with a path helper and a class

Time:10-11

I hate having to ask this but I've tried every combination and again I am tripped up by rails magic ?

<%= button_to ( "Edit this question" , options: {edit_question_path(@question)} , class: "btn btn-secondary") %>

(this is just one of 100 variations that I've tried)

CodePudding user response:

This would be the correct syntax...

button_to 'Edit this question', edit_question_path(@question), class: 'btn btn-secondary'

More in the docs on button_to

  • Related