Search code examples
ruby-on-railsruby-on-rails-3.2gmaps4rails

gmaps4rails without asset pipeline


I'm using Rails 3.2.3 and Ruby 1.9.3 along with the latest version of gmaps4rails. I am unable for the life of me to get a map to display. I keep getting JS errors stating gmap is not defined. I've followed the gmaps4rails documentation to no avail.

I think my main issue is that I do not have gmap .js files, only .js.coffee files. Am I supposed to convert the coffee script files to js files?

Any help would be greatly appreciated. I've already spent 4 hours trying to get this to work :[


Solution

  • the gmaps4rails gem doesn't care whether you have enabled the asset pipeline or not. Have a look at the generator: https://github.com/apneadiving/Google-Maps-for-Rails/blob/master/lib/generators/gmaps4rails/install_generator.rb#L8

    A quick fix would be to just copy over the js files manually.

    mkdir public/javascripts/gmaps4rails
    cp `bundle show gmaps4rails`/public/javascripts/gmaps4rails/*.js public/javascripts/gmaps4rails
    

    QnD but should get you going :-)

    Edit: the same applies for the css files of course

    cp `bundle show gmaps4rails`/public/stylesheets/gmaps4rails.css public/stylesheets/