![](/img/trans.png)
[英]Rails 3.2/Active Admin - Custom asset pipeline path not working, resulting in ActionView::Template::Error (file.js isn't precompiled)
[英]Rails ActionView::Template::Error (google_analytics.js isn't precompiled)
我决定在模板中使用javascript_inlcude_tag 'google_analytics.js'
,避免使用许多对我而言有用的工具,而支持测试新的Google Analytics(分析)“通用”功能。
问题是Google Analytics(分析)提供的代码不在Coffeescript中,因此我将其添加到我的vendor/assets/javascripts
,就像我对App中使用的许多其他库所做的一样。 但是与所有其他方法不同, javascript_include_tag
方法导致Rails停止该错误:
Rails ActionView::Template::Error (google_analytics.js isn't precompiled)
在我的许多Coofeescripts中,只是“需要”其他供应商库。
有人知道这种最新的JavaScript分析方法有什么问题吗?
同样由Dan McClain在此(相关)帖子中建议 ,通过在config/environments/production.rb
添加以下行来解决此问题:
config.assets.precompile += %w( google_analytics.js )
做完了!
先前的评论:
Google Analytics(分析)提供的代码不在Coffeescript中,因此我将其添加到了
vendor...
js不必在Coffeescript中通过直接在application.js中//= require google_analytics
包含在资产管道中,也可以是文件.js.coffee的扩展名,也可以只是.js。
话虽如此,并假设您在生产环境中遇到该错误,似乎您没有将js文件添加到资产预编译数组中。 在您的config / environments / production.rb中,需要以下行:
config.assets.precompile += %w( google_analytics.js )
希望能有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.