2013-05-07 110 views
0

我决定在我的模板中使用javascript_inlcude_tag 'google_analytics.js',避免了许多可以帮我完成测试新的Google的宝石分析“通用”功能。Rails ActionView :: Template :: Error(google_analytics.js没有预编译)

问题是Google Analytics提供的代码不在Coffeescript中,所以我将它添加到我的vendor/assets/javascripts中,就像我在我的应用程序中使用的许多其他库一样。但是,与所有其他的javascript_include_tag方法造成的Rails停止在错误:

Rails ActionView::Template::Error (google_analytics.js isn't precompiled) 

其他供应商库只是被“要求”,里面很多我Coofeescripts的。

有没有人知道这个当前的分析JavaScript方法有什么问题?

回答

1

this (related) postDan McClain同样认为,这个问题解决了通过添加以下行config/environments/production.rb

config.assets.precompile += %w(google_analytics.js) 

完成!

0

先前的评论:

Google Analytics provided code is not in Coffeescript, and so I add it to my vendor...

这是没有必要的JS是在CoffeeScript中,通过在application.js中直接//= require google_analytics或者被包含在你的资产的管道,是该文件的扩展名。 js.coffee或只是.js。

说,并假设你在生产环境中得到这个错误,似乎你没有把你的JS文件添加到资产预编译数组。在你的config /环境/ production.rb以下行需要:

config.assets.precompile += %w(google_analytics.js) 

希望帮助

相关问题