Rails 5.1.2:
我正在尝试使用 form_with 创建 AJAX 表单符合Rails documentation和 this GitHub thread .
这段代码:
<%= form_with url: '/' do |f| %>
<% end %>
事实上这段代码:
<%= form_with url: '/', remote: true do |f| %>
<% end %>
两者都会生成这个 html:
<form action="/" accept-charset="UTF-8" method="post">
<input name="utf8" type="hidden" value="..." />
<input type="hidden" name="authenticity_token" value="..." />
</form>
为什么 data-remote="true"
没有出现在 HTML 中,因为我发布的第一个链接表明它应该出现,以及如何让它出现?
最佳答案
我在使用 Rails 5.1.4 应用程序时遇到了同样的问题。使用 local: false
解决了问题。
<%= form_with url: '/', local: false do |f| %>
<% end %>
关于ruby-on-rails - Rails 5.1.2 - form_with 未在 html 中显示 data-remote ="true",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45221800/