ruby-on-rails 控制器::stimulus-loading.js importmap-rails错误

hc8w905p  于 2023-10-21  发布在  Ruby
关注(0)|答案(1)|浏览(122)

我使用Rails 6.1和@hotwired/stimulus以及importmap。
我在dev env中得到这个错误。

ActionController::RoutingError (No route matches [GET] "/assets/stimulus-loading.js")

importmap.rb:

pin "application"
pin "@hotwired/stimulus", to: "stimulus.js"
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
pin_all_from "app/javascript/controllers", under: "controllers"
pin "@hotwired/turbo-rails", to: "turbo.js"

临时解决方案是设置刺激加载预编译文件:

pin "application"
pin "@hotwired/stimulus", to: "stimulus.js"    
pin "@hotwired/stimulus-loading", to: "/assets/stimulus-loading-1fc59770fb1654500044afd3f5f6d7d00800e5be36746d55b94a2963a7a228aa.js"
pin_all_from "app/javascript/controllers", under: "controllers"
pin "@hotwired/turbo-rails", to: "turbo.js"

唯一失败的'pin'是stimulation-loading.js。为什么?我已经关注了https://github.com/hotwired/stimulus-rails任何帮助,想法或评论都是非常欢迎的。谢谢你的时间!
宝石:

'ruby' '2.6.8'
'rails', '~> 6.1'
'importmap-rails'
'stimulus-rails'
'turbo-rails'
2sbarzqh

2sbarzqh1#

似乎这为我解决了问题。尝试在config/configuration/development.rb中添加以下子句:

config.assets.debug = true

相关问题