创建新的 RailsApp 时 Rails_uis 抛出错误
2019-06-02
475
创建新的 ruby​​ 2.6 / rails6 应用程序并搭建脚手架后,destroy 弹出窗口不起作用。
知道哪里出了问题吗?突然发生。
package.json
{
"name": "untitled1",
"private": true,
"dependencies": {
"@rails/actioncable": "^6.0.0-alpha",
"@rails/activestorage": "^6.0.0-alpha",
"@rails/ujs": "^6.0.0-alpha",
"@rails/webpacker": "^4.0.6",
"turbolinks": "^5.2.0",
},
"version": "0.1.0",
"devDependencies": {
"webpack-dev-server": "^3.5.1"
}
>
控制台显示此错误:
rails-ujs.js:22 Uncaught TypeError: Cannot set property 'Rails' of undefined
at rails-ujs.js:22
at rails-ujs.js:37
at rails-ujs.js:38
at Module.<anonymous> (rails-ujs.js:822)
at Module../node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js (rails-ujs.js:822)
at __webpack_require__ (bootstrap:19)
at Object../app/javascript/packs/application.js (application.js:6)
at __webpack_require__ (bootstrap:19)
at bootstrap:83
at bootstrap:83
2个回答
github.com/rails/webpacker/issues/2109, 解决了这个问题,
在 babel.config.js 中注释掉 //corejs: 3,
希望这个 bug 能尽快得到解决。
Werner
2019-06-02
对于任何像我一样愚蠢的人,这个问答是我唯一可能的线索(这不会给你任何结果)——我遇到的 Rails 未定义问题是因为我的 javascript_include_tag 丢失了。简而言之,请确保您有:
<!-- app/views/layouts/application.html -->
<!-- turbolinks optional -->
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
ianrandmckenzie
2022-03-19