Skip to content
Extension of the Authlogic library to add Facebook Connect support built upon the excellent facebooker gem
Pull request Compare This branch is 10 commits behind kalasjocke:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Install and use

1. Install the facebooker gem and make Rails use it

$ sudo gem install facebooker

Make sure that you have setup you config/facebooker.yml to match your facebook application, make you application depended on the facebooker gem

config.gem "facebooker"

and run the xd_receiver generator to create the cross domain scripting bridge to make it possible for your application to communicate with facebook

$ script/generate xd_receiver

For more information on the facebooker gem checkout it's readme

2. Install the Authlogic Facebook Connect plugin

$ script/plugin install git://

This plugin should soon be packed inside a gem.

3. Make some changes to your database

class AddFacebookConnectFieldsToUser < ActiveRecord::Migration
  def self.up
    add_column :users, :name, :string
    add_column :users, :facebook_uid, :integer, :limit => 8

  def self.down
    remove_column :users, :facebook_uid
    remove_column :users, :name

4. Make your layout look something like this

The important parts are the facebook html namespace, facebook javascript include and the facebook helper calls to init the facebooker gem.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="" xmlns:fb="">
  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  <title>Your awsome facebook connected app</title>

  <%= stylesheet_link_tag 'application' %>
  <%= javascript_include_tag :defaults %>

  <script src="" type="text/javascript"></script>

<p style="color: green"><%= flash[:notice] %></p>

<%= fb_connect_javascript_tag %>
<%= init_fb_connect "XFBML" %>

<%= yield %>


5. Add the Facebook Connect button to your login form

<%= authlogic_facebook_login_button %>


If you want to save some user data when connecting to facebook you can use the before_connect hook in your user model.

def before_connect(facebook_session) =

For more information about what you can get form the facebook_session checkout the Facebooker gem rdoc.

Something went wrong with that request. Please try again.