Facebookin' with Ruby on Rails

Andre and I recently finished the initial launch of Placeshout’sFacebook application. There are several “getting started” tutorials available on building Facebook applications with Ruby on Rails, but there were quite a few issues we ran into that are beyond a “How To” blog entry.

If you are building your first Facebook application, expect very slow going at the start. I’d take your time estimate and double it. Here’s why:

It takes some time to grasp Facebook in a multi-developer environment. You need to create separate Facebook applications with different names using different tunneling ports. You’ll also need to create several test accounts. Inevitably, I installed one application when I meant to install another. Getting our version control system setup for our development boxes and production system took some time.

Understanding how Facebook handles sessions. We ran into several issues - knowing when to require an app install vs. a login, handling an app install redirect inside an iFrame application, etc.

We ended up using a combination of Rails’ #respond_to and unique Facebook-only actions to handle requests. Many of our pages were quite different in Facebook, and trying to fit format-handling in the existing actions only made things more confusing.

Testing was a pain. Because we integrated with Placeshout.com, we needed to integrate user accounts. Planning and testing integration steps took quite a bit of time. Facebook and rFacebook have some testing conventions, but that’s like saying that because the speedometer in my Ford Escape goes up to 120 MPH, it can go 120 MPH.

The rFacebook gem and plugin were our weapons of choice. I don’t have any complaints. We modified several pieces of code to fit our application - including creating a user and installing the application, but that’s not out-of-the-ordinary. The rFacebook team has done a solid job in a short amount of time.

In the end, it felt a lot like traveling to a non-English speaking country - at the start it’s difficult to get basic things accomplished. Once you get in a groove though, you enjoy the scenery and forget that at one time, you didn’t throw up when drinking tap water.