Rails请求失败的资产,但是资产在位置

时间:2019-01-22 04:12:36

标签: ruby-on-rails ruby webpacker

我正在使用webpacker,目前有一个请求失败

https://.../packs/application-6b70966cde4a4aebc103.js

如果我查看我的public / packs文件夹,就会看到。

deploy@platform:/var/www/.../current$ ll public/packs/
total 2427
drwxrwxr-x 2 deploy deploy     19 Jan 22 03:01 ./
drwxrwxr-x 3 deploy deploy     18 Jan 22 03:01 ../
-rw-rw-r-- 1 deploy deploy 893742 Jan 22 03:01 application-6b70966cde4a4aebc103.js
-rw-rw-r-- 1 deploy deploy 222991 Jan 22 03:01 application-6b70966cde4a4aebc103.js.gz

如果我查看日志,就会在http中看到。

5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
192.168.1.xxx - - [22/Jan/2019:04:00:51 +0000] "GET /packs/application-6b70966cde4a4aebc103.js HTTP/1.0" 404 1564 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"

在我的日志中也可以看到。

F, [2019-01-22T04:09:44.951825 #20969] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/packs/application-6b70966cde4a4aebc103.js"):
  actionpack (4.2.0) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  rollbar (2.15.5) lib/rollbar/middleware/rails/show_exceptions.rb:22:in `call_with_rollbar'
  skylight (1.4.3) lib/skylight/probes/middleware.rb:33:in `call'
  actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'

我在这里想念什么?

2 个答案:

答案 0 :(得分:0)

您是否激活了静态文件服务器?解释了here,您必须将config.public_file_server.enabledconfig.assets.compile设置为true才能为它们提供轨道。

答案 1 :(得分:0)

我忽略了它在我的http层失败的事实,因为我的nginx配置没有为我的公用文件夹设置。我出于某种原因认为Rails试图处理该请求,但后来发现这仅仅是因为它正在渲染404。Derp。