rails-ujs

Cannot find module '@rails/ujs' - Rails 6 Webpack App

被刻印的时光 ゝ 提交于 2021-01-28 01:43:00
问题 I have these errors in a Rails 6 app and all javascript is not working: ERROR in ./app/javascript/packs/application.js Module not found: Error: Can't resolve '@rails/activestorage' in '/Users/jrsahuquillo/Dropbox/myappname/app/javascript/packs' @ ./app/javascript/packs/application.js 9:0-31 ERROR in ./app/javascript/packs/application.js Module not found: Error: Can't resolve '@rails/ujs' in '/Users/jrsahuquillo/Dropbox/myappname/app/javascript/packs' @ ./app/javascript/packs/application.js 5

Using Rails-UJS in JS modules (Rails 6 with webpacker)

◇◆丶佛笑我妖孽 提交于 2019-11-27 16:03:38
问题 i just switched to Rails 6 (6.0.0.rc1) which uses the Webpacker gem by default for Javascript assets together with Rails-UJS. I want to use Rails UJS in some of my modules in order to submit forms from a function with: const form = document.querySelector("form") Rails.fire(form, "submit") In former Rails versions with Webpacker installed, the Rails reference seemed to be "globally" available in my modules, but now i get this when calling Rails.fire … ReferenceError: Rails is not defined How