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?

jslutzky
  • 419
  • 1
  • 5
  • 10

1 Answers1

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 %>
SteveTurczyn
  • 36,057
  • 6
  • 41
  • 53