Rails javascript asset missing after precompile

泪湿孤枕 提交于 2019-12-28 06:31:05

问题


the Rails Guides says:

If there are missing precompiled files in production you will get an Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError exception indicating the name of the missing file(s).

I do execute:

bundle exec rake assets:precompile

however I don't get any error, and my javascript file is missing in the manifest.yml. Also it's not appearing in public/assets, so the problem is only on production.

I have in the application.js

//= require formalize/jquery-formalize

What am I missing?

Thanks.


回答1:


Actually two things needed to do:

config.assets.precompile += %w( *.js *.css )

as described here, and

config.serve_static_assets = true

for local production testing when using

rail s

of course using

rake assets:precompile

however in my case - without config.assets.precompile this would have no effect since the manifest didn't contain any reference to my javascript file.

HTH.




回答2:


Try just:

rake assets:precompile

I've had similar issues and that has worked. You can also delete the contents of the /public/assets directory and try running it again.



来源:https://stackoverflow.com/questions/10218740/rails-javascript-asset-missing-after-precompile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!