2012-10-29 52 views
0

我有一個Rails 3.1應用程序,其資源設置爲在生產中預編譯(本例中爲Heroku)。這包括jQuery,jQueryUI和Mapstraction。運行heroku logs,然而,揭示了Mapstraction,映射JS庫,可能無法成功預編譯:Rails 3.1中的映射預編譯錯誤

2012-10-25T05:13:11+00:00 app[web.1]: ActionView::Template::Error (mxn.js?(googlev3) isn't precompiled): 
2012-10-25T05:13:11+00:00 app[web.1]:  8: <%= javascript_include_tag :application %> 
2012-10-25T05:13:11+00:00 app[web.1]:  9: <%= csrf_meta_tag %> 
2012-10-25T05:13:11+00:00 app[web.1]:  11: <%= javascript_include_tag "mxn.js?(googlev3)" %> 
2012-10-25T05:13:11+00:00 app[web.1]:  12: <script type="text/javascript"> 
2012-10-25T05:13:11+00:00 app[web.1]:  10: <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script> 

我懷疑是因爲Mapstraction(mxn.js)正在建設一個地理數據服務提供商名稱爲Rails可能無法處理的參數。它可以在開發環境中在本地工作,不需要預編譯。在這種情況下,爲什麼預編譯會失敗?

+0

不熟悉的Heroku但javascript_include_tab文檔頁面上此評論可幫助:http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/javascript_include_tag#949-When-scripts-don-t-end-in-js – dez

+0

謝謝;在這種情況下,問題並不在於它在資產預編譯過程中,它似乎不支持除靜態文件名之外的任何其他選項來選擇要預編譯的JS資產。 – huertanix

回答

0

您可以手動包括必要的文件,以使與Rails資產管道Mapstraction工作:

curl https://raw.github.com/mapstraction/mxn/master/source/mxn.js > vendor/assets/javascripts/mxn.js 
curl https://raw.github.com/mapstraction/mxn/master/source/mxn.core.js > vendor/assets/javascripts/mxn.core.js 
curl https://raw.github.com/mapstraction/mxn/master/source/mxn.openlayers.core.js > vendor/assets/javascripts/mxn.openlayers.core.js 

那麼你就把

//= require mxn 
//= require mxn.core 
//= require mxn.openlayers.core