apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

Rails 3.1 support #50

Closed mrjoshuak closed 13 years ago

mrjoshuak commented 13 years ago

Doesn't seem like this works in Rails 3.1 (3.1.0.rc4). Even if I copy over the js and css files from source I get a javascript error deep inside of google's code. ("TypeError: Result of expression 'a' [null] is not an object.")

Any ETA on when a 3.1 candidate might be available?

Thanks

gavinhughes commented 13 years ago

I'm on Rails 3.1 rc4 and the current gem 0.9.1 appears to be working fine after copying the css and js files into the assets path.

tgraham commented 13 years ago

When I use version 0.10.0 with 3.1.0.rc4 my map doesn't display correctly, had to roll back to 0.9.1 to get it working again.

I get a routing error because it's looking for /assets/gmaps4rails.googlemaps.js instead of just gmaps4rails.js

Any idea what changed? Is this a bug, or do we need to do something differently for 0.10.0?

cameel commented 13 years ago

@tgraham: Did you use the generator? I think it has not been updated in 0.10.0 and does not copy additional JavaScript files. I am using Rails 3.1.rc4 and the map works if I manually copy everything from public/javascripts, public/stylesheets and public/images in the gem to public/assets in my application.

BTW: it would be nice to have the gem working with the new asset pipeline - no more headaches when you forget to run the generator after every update.

tgraham commented 13 years ago

Yes, I used the generator, but it since it didn't create the additional files that 0.10.0 requires I'm assuming I have to pull those files from offline and move them over to my pipeline.

joeytheman commented 13 years ago

Try renaming the gmaps4rails.js to a.gmaps4rails.js. The assets engine loads the js files in alphabetical order which causes errors when the bing and googlemaps js files are loader before hand.

I also took a stab and converting the gem to use the new assets engine but did not know how to handle conditional asset includes. I started with this video http://vimeo.com/25206879

cameel commented 13 years ago

It works for me if I just copy everything to app/assets, even without renaming anything. Maybe this has been fixed in 0.10.2? Do you still experience this problem?

Anyway, I have just created a patch to make gmaps4rails use asset pipeline in Rails 3.1 and still copy files to correct locations in Rails 3 and below. https://github.com/apneadiving/Google-Maps-for-Rails/pull/59 .

Also there's an awesome guide on this topic here: http://ryanbigg.com/guides/asset_pipeline.html (note that this seems to be work in progress and not available in the official Rails Guides yet).

apneadiving commented 13 years ago

0.11.0 just released with Rails 3.1 support.