Save Facebook user data into the database after Authentication using Oauth2

November 13, 2011 § 3 Comments

This post is a reply from someone who emailed me, he asked me how to save the user data that already login to our site using facebook graph API.
after we create a login scheme using facebook and oauth2 gem, we need to save the facebook user data to our databases, so.. how to save it into the database?

it’s very easy and simple, when we get a callback from the facebook graph API and save the user data in session like this:

session[:fb_user] = JSON.parse access_token.get('/me')
session[:user] = User.save_user_data(session[:fb_user])

« Read the rest of this entry »


how to make layout false for devise controller

July 5, 2011 § Leave a comment

since I wanna use the login page as a popup box use facebox.. not to redirected the user. the whole layout is appear to the facebox.. so how to make the layout false if we use devise?

simple.. check the current controller is a Devise::SessionsController or not in ApplicationController :

class ApplicationController < ActionController::Base
  layout :layout


  def layout
    is_a?(Devise::SessionsController) ? false : "application"


facebook authentication using oauth2 gem in rails

July 26, 2010 § 4 Comments

in this section,  i wanna share how to intregrate the Facebook’s new OAuth authorization in Ruby On Rails, using oauth2 gem.

let’s get started !

first, install the oauth2 gem, you can get it from here

then create a controller call oauth_controller.rb « Read the rest of this entry »

Where Am I?

You are currently browsing the facebook category at Kubid on rails blog.