Reputation: 3659
I'm trying to use geocomplete_rails gem: https://github.com/guyisra/geocomplete_rails
My application.js
file looks like this:
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require moment
//= require bootstrap-datetimepicker
//= require geocomplete
//= require_tree .
$(function() {
$('#event_raw_location').geocomplete();
});
When I open form page with #event_raw_location
element, I get Uncaught ReferenceError: google is not defined
error and autocomplete does not work. Any idea why?
Upvotes: 3
Views: 768
Reputation: 9639
From the documentation in here it looks like you should add one more JavaScript.
Try adding following line in your app/views/layouts/application.html.erb:
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
before line:
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
Hope that helps!
Upvotes: 2