Werner
Werner

Reputation: 309

Rails_uis throw error when creating a new RailsApp

After creating a new ruby 2.6 / rails6 app and scaffolding the destroy popup is not working.

Any idea whats wrong.. happens out of sudden..

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"
}

}

console shows this error:

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

Upvotes: 1

Views: 481

Answers (2)

ianrandmckenzie
ianrandmckenzie

Reputation: 482

For anyone that is as catastrophically dumb as I am with this Q/A as my only possible lead (that will take you nowhere) – My issue with Rails being undefined was that my javascript_include_tag was missing. In short, make sure you have:

<!-- app/views/layouts/application.html -->
<!-- turbolinks optional -->
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

Upvotes: 0

Werner
Werner

Reputation: 309

github.com/rails/webpacker/issues/2109, solves the problem,

comment out //corejs: 3, in babel.config.js

Hopefully the bug will be solved soon.

Upvotes: 1

Related Questions