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') %>
1

3 Answers 3

1

Try this

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

This works fine for me

Sign up to request clarification or add additional context in comments.

Comments

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'}) %>

Comments

0

Try this:

<%= button_to "Logout", session_url, method: :delete, form_class:"waves-effect waves-light btn-large" %>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.