5

I am following the simple tutorial here: https://github.com/JonKernPA/gmaps

I keep getting the error:

couldn't find file 'underscore'
    (/app/assets/javascripts/application.js:16)

with the following line highlighted:

<%= javascript_include_tag "application", "data-turbolinks-track" => true %>  

I tried following the suggestions posted in Gmaps is not defined in rails 4 + gmaps4rails 2.0.3

and I get the same error with the error with the same line highlighted. When I try to remove the line

<%= javascript_include_tag "application", "data-turbolinks-track" => true %>  

from application.html.erb, I get the error "Gmaps not found"

Any help appreciated, thanks. Github link: https://github.com/chiefkikio/circus/

Community
  • 1
  • 1
chiefkikio
  • 275
  • 2
  • 11

4 Answers4

16

Found a solution. Had to install gem 'underscore-rails' and then bundle it and restart the rails server.

chiefkikio
  • 275
  • 2
  • 11
1

Not a tutorial project, but I use gem 'underscore-rails' (cf https://rubygems.org/gems/underscore-rails) to satisfy gmaps4rails' dependence.

Bob Mazanec
  • 1,121
  • 10
  • 18
0

The minified version of Underscore has this line at the end of the file:

//# sourceMappingURL=underscore-min.map

Chrome's developers tools will try to download underscore-min.map when encountering this line. Users won't see this error, unless they open developer tools.

If you want to get rid of this error, either add underscore-min.map to your project (https://github.com/jashkenas/underscore/blob/master/underscore-min.map) or remove that line from underscore.min.js

Lucas Ocon
  • 189
  • 2
  • 7
0

I also faced the issue and this is what was the reason for me: The order of required files in my application.js was wrong. I required //= require_tree . before gmaps. And since I didn't wait until page load in my controller_name.js file, it was loaded first, trying to use Gmaps before the latter was defined.. I thought it might help, but.. I run into another couple issues with ".. is not defined". After small research here is the solution: wrap you whole custom js in callback for window.load event. I used it with this line:

google.maps.event.addDomListener(window, "load", callback)

Hope this will help

aprok
  • 1,147
  • 11
  • 25