As per the facebook policies we need to log the user out of the facebook when he clicks sign\_out in the app.

To achieve this there are many ways, some of them got deprecated. One way that is suggested by facebook is to use their [Facebook Javascript SDK (Facebook Javascript sdk)][1]


[Logout of facebook in rails(Logout of facebook in rails)][2]

I used following code in document ready to achieve this functionality.

  window.fbAsyncInit = function() {

        appId: window.fb_app_id,
        status: true,
        cookie: true,
        xfbml: true,
        oauth: true

    $('#sign_out').click(function(e) {
        FB.getLoginStatus(function(response) {
            if (response.authResponse) {
                 FB.logout(function(response) {
        return false;
(function(d) {
    var js, id = 'facebook-jssdk';
    if (d.getElementById(id)) {
    js = d.createElement('script'); = id;
    js.async = true;
    js.src = "//";

Few points regarding this code:

        FB.logout(function(response) {

The url which we pass here is the url that points to actual signout of the app and that sould be handled in the callback. otherwise the user will be logged out of the app but not from the facebook due to async nature of the FB.logout()

Note: View should contain a div with id as "fb-root" for the initialization process.