Ask A Question


You’re not receiving notifications from this thread.

Google Maps and Google Places Autocomplete API with Rails, Turbolinks, and Stimulus.js Discussion

Thanks Chris, great video.

I have tried to work with Google Maps Places API in the past, but I have faced an issue with their API Policies. According to their policy you cannot save details like the place address which was autocompleted in your application database (,-caching,-or-storage-of-content). Also I remember you can save the latitude and the longitude in the database but you have to refresh it every 30 days (

What are your thoughts on this?


It sounds like they more or less don't want you downloading all their data and creating your own copy. That's their way of enforcing it. There are several good alternatives that might have better licensing.


So does that mean that you are good if the app runs a place update each month? If so, for smaller apps, you are golden. The Mapbox API might be a good alternative.

Overall, thanks Chris for offering this look into how to use Google's API with rails. I haven't seen anyone put something like this together in a while.


Awesome episode Chris!

Would love to see more on Stimulus!


Me too. I prefer Stimulus over all other options. Is the Rails way. So easy and useful.


Hi Chris, Great tutorial. I noticed that when you go back to edit a page, the map loads the correct location from lat and long, however, it does not place the marker back. It would be confusing for users let's say on a property details page when the page loads, it will zoom to the correct building/area but since the marker for the actual address didn't load, the user won't know which building they are looking at. Instead they are going to be looking at the whole map with other business names and their markers. In summary, when you go back to your edit page (from your screencast) it should load the marker.


Great tutorial! With your setup I think you should be getting the same issue I am where once you set the place, if you delete the field the place is still saved. It only changes when you select a valid new place. Is there a way to delete the lat/long when an invalid place is selected or no place is?


Hey Chris, great tutorial!
When I was implementing I noticed that the Event.initEvent() method is deprecated.
So I changed it to use the Event constructor instead:

window.initMap = function (...args) {
  const event = new Event('google-maps-callback', { bubbles: true, cancelable: true });
  event.args = args;
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 71,933+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2023 GoRails, LLC. All rights reserved.