I am working in Rails 3.2.11 and I cannot figure out why this button will not render per the API documentation. Specifically, I cannot get the data-remote attribute to render correctly. Is there a bug in my code?
Right now this code:
<%= button_to "Test", :action => "test", :remote => true, :form_class => "test_button" %>
yields this HTML:
<form action="/cloud_status/test?form_class=test_button&remote=true" class="button_to" method="post">
Per the API specs it should render this:
<form action="/cloud_status/test" class="test_button" remote="true" method="post">
What am I missing?
I believe the documentation is actually incorrect here in some of the examples. The way to get the output you are looking for is:
The
:remoteand:form_classshould be part of thehtml_optionshash, which is the third parameter of thebutton_tomethod.The second parameter can either be a
StringorHash. When it’s aStringit’s treated as a URL and when it’sHashit is passed tourl_forto build the appropriate URL.