Missing assets in production

AI 生成的摘要

In a discussion titled “Missing assets in production” within the Dev category, user sevenmaxis reports that despite setting up a production database and precompiling assets in a Vagrant environment, the site fails to load JavaScript files, resulting in 404 errors and ReferenceError exceptions for require and Ember.

User sam suggests running the precompile command with the production environment flag:

RAILS_ENV=production bin/rake assets:precompile

sevenmaxis confirms this was already done, noting that the assets exist in the public/assets directory but remain inaccessible. The issue is ultimately resolved when sevenmaxis identifies the root cause as a missing configuration in Rails: setting config.serve_static_files = true enables the server to serve the precompiled static assets correctly.

I’m developing under vagrant. To resolve problem with plugin I need to run project in production environment.
I’ve setup production database, precompiled assets and etc. But assets are not available.

GET http://localhost:4000/assets/locales/en-804ed863fc64c411df3e2c34601396de651ac49b36c280044a57afdd8c530130.js 
(index):43 GET http://localhost:4000/assets/ember_jquery-fd1152747e1d8d273f929f46a9de5fcbd1aeaf4d6f102306216787b3b29b41c2.js 
(index):44 GET http://localhost:4000/assets/preload-store-8f2c6a229e802a79c2fdcad50fd4be24b48ae5ea509967a9c04ea1505fec45a4.js 
(index):45 GET http://localhost:4000/assets/vendor-b2e884ad30ed6971a659ed1b04572cb5645a31a7d226dbf6ffaa1658201ea452.js 
(index):46 GET http://localhost:4000/assets/pretty-text-bundle-7f6667577c3caba87c12a26f913649744ed32f2c0e16f4e7778a8563ecfd8e11.js 
(index):47 GET http://localhost:4000/assets/application-266552f6665a9044fc1b5bedd130662b2ae131d32d2247233bf07bc13d34c9c2.js 
(index):153 Uncaught ReferenceError: require is not defined(anonymous function) @ (index):153(anonymous function) @ (index):161
(index):167 Uncaught ReferenceError: Ember is not defined(anonymous function) @ (index):167
(index):180 Uncaught ReferenceError: require is not defined(anonymous function) @ (index):180(anonymous function) @ (index):193
(index):196 GET http://localhost:4000/assets/browser-update-bfd8d36f8afbc3c7eab69f8d69878f97851c57a2cae626aa38c6c2563a716732.js 404 (Not Found)

What might be a problem here?

precompile your assets…

RAILS_ENV=production bin/rake assets:precompile

Already done, I can see these assets in public/assets folder, but they are not accessible from site.

vagrant@discourse:/vagrant/public/assets$ l
admin/
admin-0b5f3103e39b430afbea63008b61940145c90ccc21c21c029e5aa70a8cca552c.css
admin-0b5f3103e39b430afbea63008b61940145c90ccc21c21c029e5aa70a8cca552c.css.gz
admin-649952ed232495461c925de0a2d8e812c0118b61a536f84b955b26ced2b7c7d5.js
admin-649952ed232495461c925de0a2d8e812c0118b61a536f84b955b26ced2b7c7d5.js.gz
application-266552f6665a9044fc1b5bedd130662b2ae131d32d2247233bf07bc13d34c9c2.js
application-266552f6665a9044fc1b5bedd130662b2ae131d32d2247233bf07bc13d34c9c2.js.gz
...

The problem was with the rails’ serving static files configuration:

config.serve_static_files = true