Deploying a Rails app on Heroku (paperclip, gems, yml)

I just moved my PlaygroundsRUs site from AWS to Heroku, and I couldn’t be happier. My first full month bill from Amazon was about $75, and $74 of that (99% of the total cost) was for running an instance. Harlan told me about Heroku after he deployed his ForkThis demo on there.

Most of the transition was smooth, but there were a few hiccups on the way. One of them still hasn’t been resolved (one of the plugins is having conflict with PostgresSQL, which is used by Heroku). I will enumerate what I had to go through so that it might be easier for you.

1. Secret YAML files

I have a public GitHub account for deploying on AWS using ec2onrails. Since it’s public and anyone can see it, I had to omit sensitive


files in config directory that contained passwords and keys. It’s easily done by specifying those files in


and listing them in




used by ec2onrails.

I found out that for Heroku, the same can be achieved by creating another branch, including those files, merging with master, and pushing it to Heroku. So, the following lines should do the trick.

git checkout production
[remove those yml files from .gitignore]
git merge master
git push heroku production:master

Continue reading

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.