简体   繁体   English

Rails 3.1中的Mapstraction预编译错误

[英]Mapstraction Precompilation Error in Rails 3.1

I have a Rails 3.1 application with assets set up to pre-compile in production (Heroku, in this case). 我有一个Rails 3.1应用程序,其资产已设置为在生产中进行预编译(在这种情况下为Heroku)。 This includes jQuery, jQueryUI and Mapstraction. 这包括jQuery,jQueryUI和Mapstraction。 Running heroku logs , however, reveals that Mapstraction, a mapping JS library, may not be pre-compiling successfully: 但是,运行heroku logs表明,映射JS库Mapstraction可能未成功预编译:

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>

I suspect that since Mapstraction (mxn.js) is being constructed with a geodata service provider name as a parameter that Rails might not be able to handle that. 我怀疑由于Mapstraction(mxn.js)是使用地理数据服务提供商名称作为参数构造的,因此Rails可能无法处理该参数。 It works locally in a dev environment though, without precompiling. 但是,它无需开发即可在开发环境中本地工作。 Any ideas on why precompiling would fail in this case? 关于为什么在这种情况下预编译会失败的任何想法?

You can manually include the necessary files to make Mapstraction work with the Rails asset pipeline: 您可以手动添加必要的文件,以使Mapstraction与Rails资产管道一起工作:

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

then you put 然后你把

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM