Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7431079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:14:22+00:00 2026-05-29T09:14:22+00:00

We are new to rails and are looking to use the Javascript SDK Connect

  • 0

We are new to rails and are looking to use the Javascript SDK “Connect with Facebook” button on our homepage. Using this button in our app, we want to allow users to sign up for our site via Facebook, and be able to use their Facebook profile picture as their profile image for our web app.

What is the best way to implement this Facebook Connection with our Rails 3 app?

  devise_for :users

  resources :authentications

  resources :users do
      member do
        get :following, :followers
      end
  end
  resources :sessions,   :only => [:new, :create, :destroy]
  resources :microposts, :only => [:create, :destroy]
  resources :relationships, :only => [:create, :destroy]

  match '/signup',  :to => 'users#new'
  match '/signin',  :to => 'sessions#new'
  match '/signout', :to => 'sessions#destroy'
  match '/contact', :to => 'pages#contact'
  match '/home',   :to => 'pages#home'
  match '/help',    :to => 'pages#help'
  match '/feedback',    :to => 'pages#feedback'
  match '/privacy',    :to => 'pages#privacy'
  match '/terms',    :to => 'pages#terms'
  match '/',        :to => 'pages#home'

  resources :microposts

  resources :users
  resources :sessions, :only => [:new, :create, :destroy]


  root :to => 'pages#home'

  match "/auth/twitter/callback" => "sessions#omnicreate"
  match "/auth/facebook/callback" => "sessions#omnicreate"


end

SessionsController

class SessionsController < ApplicationController

  def new
    @title = "Sign in"
  end

  def create
      user = User.authenticate(params[:session][:email],
                           params[:session][:password])
      if user.nil?
        flash.now[:error] = "Invalid email/password combination."
        @title = "Sign in"
        render 'new'
      else
        sign_in user
        redirect_back_or user
      end
  end

  def destroy
        sign_out
        redirect_to root_path
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:14:23+00:00Added an answer on May 29, 2026 at 9:14 am

    Looks like you need to do a couple things:

    Change these lines in your routes file:

      root :to => 'pages#home'
    
      match "/auth/twitter/callback" => "sessions#omnicreate"
      match "/auth/facebook/callback" => "sessions#omnicreate"
    

    To this:

      match "/auth/:provider/callback" => "sessions#omnicreate"
    
      root :to => 'pages#home' # this one should always be last
    

    Both Twitter and Facbook are going to the same method so you will need to get that :provider param out later on to figure out if its Twitter or Facebook that sent them.

    Next you need to create a method in your SessionsController that receives the callback like this:

    def omnicreate
    
      data = request.env['omniauth.auth'] # here is all the user data
      if params[:provider] == 'twitter'
         #parse twitter data
      elsif params[:provider] == 'facebook'
         #parse fb data
      else
         # something is broken
         redirect_to '/404.html'
      end
    
      user = User.create! #use data you parsed to create a user
      redirect_to some_path, :notice => 'awwww yeah'
    end
    

    good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Ruby on Rails, looking at using it for an app that
We are getting close to releasing our new rails app and so far interest
I'm looking to use the latest Twitter gem for a Rails app I'm working
I'm kinda new to using Rails, and an app I am working on is
We want to use Nagios for monitoring a Rails app. The reason is we
I'm new to Ruby on Rails (I know Ruby just decently though) and looking
Starting a new rails project and we have a well-thought-out color palette, and want
I've set up a new Rails 2.3.2 app and added the Basecamp API ruby
I am working on the admin section of a new rails app and i'm
I'm migrating my old blog posts into my new Rails blog, and I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.