I´m developing an website in ROR
I am using gem 'gmaps4rails'.
In localhost the map is showed, but when i put on a production server (DigitalOcean) gives me this error: Uncaught ReferenceError: Gmaps is not defined
i have this script in my index.html.erb:
<div id="map_show" ></div>
</div>
<script type="text/javascript">
handler = Gmaps.build('Google');
handler.buildMap({ provider: {}, internal: {id: 'map_show'}}, function(){
markers = handler.addMarkers(<%=raw @hash.to_json %>);
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});
</script>
My application.js is this:
//= require jquery
//= require bootstrap-sprockets
//= require jquery_ujs
//= require turbolinks
//= require underscore
//= require gmaps/google
//= require highcharts
//= require chartkick
//= require_tree .
Anyone know how can i resolve my problem?
EDIT 1
Application.html.erb:
<!DOCTYPE html>
<html>
<head>
<title>ThomarWeb - Site espectacular de Turismo</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag "gmaps4rails" %>
<%= javascript_include_tag "gmaps4rails" %>
<!--<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA4BHW3txEdqfxzdTlPwaHsYRSZbfeIcd8&callback=initMap"
async defer></script>-->
<script src="//maps.google.com/maps/api/js?key=AIzaSyA4BHW3txEdqfxzdTlPwaHsYRSZbfeIcd8"></script>
<script src="//cdn.rawgit.com/mahnunchik/markerclustererplus/master/dist/markerclusterer.min.js"></script>
<script src='//cdn.rawgit.com/printercu/google-maps-utility-library-v3-read-only/master/infobox/src/infobox_packed.js' type='text/javascript'></script> <!-- only if you need custom infoboxes -->
</head>
<body>
<%= render 'layouts/header' %>
<div class="container-fluid">
<% flash.each do |name, msg| %>
<%= content_tag(:div, msg, class: "alert alert-info") %>
<% end %>
<%= yield %>
</div>
</body>
</html>
I was following this tutorial: https://gorails.com/deploy/ubuntu/16.04#nginx-passenger
SOLVED!
I solve my problem. The problem is the javascripts files in the server.
I need to use CDN:
<script src='//cdn.jsdelivr.net/gmaps4rails/2.1.2/gmaps4rails.js'> </script>
<script src='//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js'> </script>