How to integrate Google Maps in a Rails app

The major part of my experiment was going to be the integration with Google Maps. At first, I was a bit apprehensive about it, but Ruby on Rails being a community oriented language, I found a couple of quite useful plug-ins. With them, finding a location based on address or geocode or finding nearby places based on certain radius of a location were not too hard.

There is actually an excellent book also, called Beginning Google maps applications with Rails and Ajax. But the problem with the book is that it was geared towards more for java developers using rails. Thus, its major functions were javascripts and it showed how to talk to rails app. In my case, since I wanted simple features and I didn’t want to take time to learn javascript, I decided to find a simpler way.

And I found that for things I wanted to do, I could do with YM4R/GM and Geokit. There are other excellent tutorials out there like the one by Jason Gilmore on

Let’s begin.

1. Sign-up for Google Maps API by going to here. For development environment, you can use either http://localhost:3000 or as the website URL. Copy the API key.

When you move to production environment, make sure you come back here to get another key for production URL.

Continue reading

How to integrate Facebook Connect with a Rails app

Update: I have written up another post for using Devise and Omniauth, and you can find it here. Facebooker is no longer maintained.

Top of my to-do list was to integrate Facebook Connect with my Rails app, since 1) there are A LOT of people using Facebook and 2) having to register to post or edit could be an obstacle in getting more users to use my site.

I looked on the web for a while, and found a great example by Stuart Eccles at Made by Many. It’s an awesome tutorial, but it’s for restful_authentication. I don’t use it, so I had to modify it a little bit. Also, I added a step to ask a user to pick a username. So the following instruction is basically modification of Stuart’s.

Without further ado, let’s begin.

1. Setup Facebook Application page

1.1. Go to this page, and enter a name for your application. I named mine “Playgrounds_R_Us”.

1.2. Make a note of Application ID, API Key, and Secret. You need it for facebooker.yml later.

1.3. Next is Authentication section. Here what’s important is Post-Authroize and Post-Remove Callback URL. They refer to a web page a user will be taken to after logging into and logging out of Facebook account. While testing, I left it at “”.

1.4. I also used the same URL ( for Canvas Callback URL in Canvas section and Connect URL in Connect section.

1.5. Then you are pretty much set with configuration on Facebook side.

2. Get facebooker plugin and install it. From your rails app root directory,

ruby script/plugin install git://

Continue reading

Driving direction and link to edit playground information

I just updated the PlaygroundRUs site with driving direction option in info text bubble of a marker. Two buttons, “To Here” and “From Here”, are available. For now, they just open a new tab or window to Google Maps page with destination or source address of the playground.

There is a way to make it more dynamic – clicking “To Here” or “From Here” brings up a text field, where it asks where from/to address. However, this requires the logic to be placed in the javascript world. In my code, all the markers and info text bubble information are prepared in Ruby. To make it more dynamic, I need to put the logic in javascript, and it will take a while to do it.

By the way, there is an excellent set of tutorials that show how to work with Google Maps API here, all in javascript.

I also moved “Edit Playground Info” link to next to the Playground name to make it more obvious.

Next Up: Integrating with Facebook Connect.

Alpha version of Playgrounds R Us is launched

I’ve been working on it for three months or so, and it’s gotten to a point where it’s usable. It’s my first Ruby on Rails application, and this was a lot better and easier than when I tried to learn it a few years ago. That’s not to say it was that easy. I certainly have stumbled a lot, but web has been good to me. Any road blocks, I can always search for a solution online. Also many plugins have made my life very easy. I’ve resolved many issues, and I wish I could have made a record of how I resolved them. In fact, I will try to do that in my next several postings. I have found those instructional blog posts very helpful, and hopefully I will contribute some back to the community.

Website: Playgrounds R Us

Plugins used:

Gems used: