1

I am trying to add a class to a button generated with rails button_to helper, but I cannot find a consistent answer to the question of how to incorporate the class into the declaration. I have:

 <%= button_to("Logout", session_url, method: :delete, class:'waves-effect waves-light btn-large') %>
Marc Fletcher
  • 932
  • 1
  • 16
  • 39
  • 1
    this might help you http://stackoverflow.com/questions/14123884/rails-button-to-applying-css-class-to-button – titan Aug 10 '16 at 04:11

3 Answers3

0

You need to split the "html options" from the "make the button_to" options - ie make two separate hashes eg:

<%= button_to("Logout", session_url, {method: :delete}, {class:'waves-effect waves-light btn-large'}) %>
Taryn East
  • 27,486
  • 9
  • 86
  • 108
0

Try this:

<%= button_to "Logout", session_url, method: :delete, form_class:"waves-effect waves-light btn-large" %>
Hasmukh Rathod
  • 1,108
  • 1
  • 14
  • 20
0

Try this

<%= button_to("Logout", session_url, method: :delete, :class => "btn btn-success") %>

This works fine for me

Pradeep Sapkota
  • 2,041
  • 1
  • 16
  • 30