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

  • SEARCH
  • Home
  • 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 8958943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:19:58+00:00 2026-06-15T15:19:58+00:00

I am trying to use Omniauth facebook with two devise models in a Rails

  • 0

I am trying to use Omniauth facebook with two devise models in a Rails 3 app. Currently that’s not something that’s possible using omniauthable and the devise helpers.

A similar question answered how to do this:

Omniauth "with" STI and devise

“..move your omniauth configuration from devise.rb to omniauth.rb and create your own omniauth routes.’

But I am having trouble in defining these routes and helpers, i.e. for facebook I used a devise helper like this:

user_omniauth_authorize_path(:facebook) 

..which redirected to facebook and then placed a callback URL I set up in my devise_for scope.

What would my routes/helpers look like for the omniauth-facebook strategy if setting up manually?

I already had omniauth-facebook and devise nicely working for the ‘User’ model before, so I have the various

@user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user, params[:state])

..parts ready to go, but now with two models. I’m just having trouble with replacing the devise helpers I think.

  • 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-06-15T15:20:00+00:00Added an answer on June 15, 2026 at 3:20 pm

    Your link should look this this:

    <%= link_to "Sign in with Facebook", "/auth/facebook" %>
    

    You also have to create some callback routes, and there are 2 ways you could do this. You can either:

    1. Define a route that catches all callbacks and redirects to a single controller’s action:

      get "/auth/:provider/callback" => "authentications#create"
      

      You can then use params[:provider] to get the name of the provider. Using an if you could then do things differently depending on the provider.

    2. Or define a route for every single provider where you can point to different actions in your controller:

      get "/auth/twitter/callback" => "authentications#twitter"
      get "/auth/facebook/callback" => "authentications#facebook"
      

      These routes can also be condensed in a single route:

      get "/auth/:action/callback",
        :to => "authentications",
        :constraints => { :action => /twitter|facebook/ }
      

      You would then need to define these actions. In the twitter action you could fetch the user’s tweets and in the facebook action you could fetch the user’s posts, for example.

    Also, don’t forget to create the failure action to deal with the situation where a user does not authorize logging in with a certain provider.

    Now, you will come across a problem. How do you find out where the link should point to? For Twitter and Facebook, it seems pretty obvious (/auth/twitter and /auth/facebook, respectively).

    But what if you are using the omniauth-google-oauth2 gem to sign in using Google+? Your only hope is that each omniauth gem (listed here) has some good documentation.

    In any case, if you don’t know the url you’re supposed to use or if you simply don’t like the url used by a certain gem, you can always change it!

    For example the url /auth/google_oauth2 is certainly not pretty, at least compared to facebook’s and twitter’s urls. To change the url, use the name option.

    # omniauth.rb, when using pure omniauth
    provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'],
      {
        name: 'google'
      }
    
    # devise.rb, when using omniauth+devise
    config.omniauth :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'],
      {
        name: 'google',
      }
    

    Now you can use the url /auth/google, much better.

    Note: I made several references to an AuthenticationsController but maybe what you have is a CallbacksController or an OmniauthCallbacksController, it doesn’t really matter what you call it.

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

Sidebar

Related Questions

I'm trying to build a new rails 3 app from scratch using OmniAuth. Currently
I'm trying to get Facebook logins working on my app using Rails, Authlogic, and
I'm currently trying to use omniauth in my rails application. I was just curious,
I'm trying to use omniauth-twitter in a rails app, but i'm stuck at the
I am trying to set the fb app id (used by omniauth) so that
I'm trying to implement OmniAuth for Facebook in tandem with AuthLogic. I'm currently getting
I'm trying to use OmniAuth in a sinatra app with google as the login
I have a Rails app and I am trying to test it. I use
I've followed Railscast 360 to setup Omniauth-Facebook authentication for my Rails app. The authentication
I am new to Rails and I am trying to use omniauth with rails

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.