预编译后缺少 Rails javascript 资产
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10218740/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Rails javascript asset missing after precompile
提问by valk
the Rails Guidessays:
在Rails的导游说:
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).
如果生产中缺少预编译文件,您将收到 Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError 异常,指示丢失文件的名称。
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.
但是我没有收到任何错误,并且manifest.yml 中缺少我的 javascript 文件。它也没有出现在public/assets 中,所以问题只出现在生产中。
I have in the application.js
我在application.js
//= require formalize/jquery-formalize
What am I missing?
我错过了什么?
Thanks.
谢谢。
回答by valk
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.
但是在我的情况下 - 没有 config.assets.precompile 这不会有任何影响,因为清单不包含对我的 javascript 文件的任何引用。
HTH.
哈。
回答by Joe Saunders
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.
我遇到过类似的问题,并且奏效了。您也可以删除/public/assets
目录的内容,然后再次尝试运行它。