Mapstraction Precompilation Error in Rails 3.1

106 Views Asked by At

I have a Rails 3.1 application with assets set up to pre-compile in production (Heroku, in this case). This includes jQuery, jQueryUI and Mapstraction. Running heroku logs, however, reveals that Mapstraction, a mapping JS library, may not be pre-compiling successfully:

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. It works locally in a dev environment though, without precompiling. Any ideas on why precompiling would fail in this case?

1

There are 1 best solutions below

0
On

You can manually include the necessary files to make Mapstraction work with the Rails asset pipeline:

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