Rails 5.1.2-form_with未显示data-remote ="true".在html中 [英] Rails 5.1.2 - form_with is not showing data-remote="true" in the html

查看:121
本文介绍了Rails 5.1.2-form_with未显示data-remote ="true".在html中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Rails 5.1.2:

Rails 5.1.2:

我正在尝试使用 form_with Rails文档和此GitHub线程.

此代码:

<%= 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中,正如我发布的第一个链接表明它应该出现,以及如何使其显示?

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?

推荐答案

data-remote的默认值由选项Rails.application.config.action_view.form_with_generates_remote_forms配置.在Rails 5中,默认情况下此选项为true.在所有项目中进行搜索,似乎您是从Rails 4或smth迁移的.否则将覆盖此选项.

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.

这篇关于Rails 5.1.2-form_with未显示data-remote ="true".在html中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆