0

I'm trying to add a class with button_to in Rails, but I keep getting syntax errors. This is what I've got:

<%= button_to "Update this task", user_task_path(current_user, task), method: "patch", remote: true, {class: "update"} %>

I've tried putting various things in and out of braces but I can't get it to work. Any ideas?

1 Answer 1

1

EDIT

Try using form_class (which will assign the class for you)

<%= button_to "Update this task", user_task_path(current_user, task), method: "patch", remote: true, form_class: "update" %>

Failing that, a more long-winded solution...

<%= button_to user_task_path(current_user, task), {method: "patch", remote: true}, {class: "update"} do %>
  Update this task
<% end %>
Sign up to request clarification or add additional context in comments.

1 Comment

Hmm, that gave me "wrong number of arguments (4 for 0..3)".

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.