Rails 5.1.2:
I'm trying to create an AJAX form using form_with in line with the Rails documentation and this GitHub thread.
This code:
<%= form_with url: '/' do |f| %>
<% end %>
and in fact this code:
<%= form_with url: '/', remote: true do |f| %>
<% end %>
both produce this html:
<form action="/" accept-charset="UTF-8" method="post">
<input name="utf8" type="hidden" value="..." />
<input type="hidden" name="authenticity_token" value="..." />
</form>
Why isn't data-remote="true"
appearing in the HTML, as the first link I have posted indicates it should, and how do I get it to appear?
I was having the same problem with a Rails 5.1.4 app. Using local: false
fixed the problem.
<%= form_with url: '/', local: false do |f| %>
<% end %>
Default value for data-remote
is configured by option Rails.application.config.action_view.form_with_generates_remote_forms
. By default in Rails 5 this option is true
. Search this through all your project, it seems that you migrated from Rails 4 or smth. else with overriding this option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With