I’ve signed up for Facebook today to check out how the whole application development works. Setting up a development server at home which is accessible from Facebook is pretty straight forward.
Here’s what you need:
- Facebook account
- Local box with Apache
- Domain name pointing to your home IP. I use No-Ip.
Here are the steps I took.
- Setting up development application on Facebook. Follow the guide, it’s pretty straight forward.
- Set up No-Ip to point
*.dev.mydomain.comto my local box. This allows me to create as many Rails applications as I need to. - Configured Apache to forward all calls to
fbtest.dev.mydomain.comtolocalhost:3000using mod_proxy like so:<VirtualHost *:80> ServerName fbtest.dev.mydomain.com ProxyPass / http://127.0.0.1:3000/ </VirtualHost>
gem install rfacebookcd /anywhere/fbtestrails .ruby script/plugin install svn://rubyforge.org/var/svn/rfacebook/plugins/rfacebook_on_railsrake facebook:setup- Go to http://www.facebook.com/developers/apps.php
- Copy and paste API key and secret to
config/facebook.yml. Setcanvas_pathto the local path on Facebook, ie/myfacebookapp/andcallback_pathto local path on your server, ie/facebook/. ruby script/generate controller facebook index- Edit index method in Facebook controller, like so:
class FacebookController < ApplicationController def index @result = fbsession.friends_get.uid_list end end - Edit index.rhtml like so:
<% @result.each do |uid| %> <fb:name uid="<%= uid %>" /> <% end %>
- Start Apache
ruby script/server- Now you should be able to hit your Facebook application page at
http://apps.facebook.com/myfacebookapp
You should see a list of your friends. Took me about 30 minutes to figure all this out.
12 Responses to “Hello Facebook in Rails”


August 21st, 2007 at 7:17 pm
[…] Hello Facebook in Rails (tags: Facebook rubyonrails plugin rfacebook) […]
August 23rd, 2007 at 3:45 pm
[…] Hello Facebook in Rails […]
August 23rd, 2007 at 7:38 pm
Thanks for the clean, simple tutorial Alex. I’d like to also note the main documentation is also on the RFacebook homepage:
http://rfacebook.rubyforge.org
August 27th, 2007 at 11:37 pm
Don’t forget to add this to your controller to actually request login.
before_filter :require_facebook_login
September 4th, 2007 at 9:42 pm
can be more details, many of the steps are left out.
is the app fbml or iframe ?
November 2nd, 2007 at 6:25 am
Hey Do you know any ways to put google maps in Facebook application I have done it with iframe but with this I dont have access to map object outside the frame .
Please send me the reply I you have any solution.
November 2nd, 2007 at 12:44 pm
@Bhurshan,
I don’t think you have many options for GMaps. Facebook sandboxes all JS, so you can’t include it straight. If you need to have maps, the only two options i can think of are flash and iframe. You can use flash with Yahoo Maps.
November 7th, 2007 at 7:46 am
Hello Alex,
thanks for the tutorial!
One thing I would like to know, though: Does Facebook provide any kind of hosting service for their members, or are we required to host our rails applications for facebook on our own webspace?
Kind regards,
Rainer
November 7th, 2007 at 10:36 am
@ Rainer,
facebook is byoh - bring your own hosting.
November 8th, 2007 at 1:34 am
Hey all,
Had you done some functionality with the google maps in the FB app. I am using it in my app but not be able to access the object of the map, i am using it in an iframe. Could you suggest me some thing.
December 12th, 2007 at 10:22 am
[…] Hello Facebook in Rails […]
February 20th, 2008 at 1:55 am
The names of my friends are getting displayed by using this code:
” />
If I do following
it will display uids of all my friends.
Any idea if I am missing anything?