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 6615561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:28:38+00:00 2026-05-25T20:28:38+00:00

I’ve been pulling my hair for hours on this one… I have a Devise

  • 0

I’ve been pulling my hair for hours on this one… I have a Devise and omniauth setup that allows users to log in with their Facebook accounts. I am using the following gem versions:

Installing devise (1.4.7)
Installing oauth2 (0.4.1)
Installing oa-oauth (0.2.6)
Installing omniauth (0.2.6)

among others and have the app id and secret in my Devise initializer:

config.omniauth :facebook, 'app_id', 'app_secret',
          {:scope => 'email, offline_access', :client_options => {:ssl => {:verify => false}}}

Though I also tried this with no luck:

config.omniauth :facebook, 'app_id', 'app_secret',
          # {:scope => 'email, offline_access', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}

I have the :omniauthable directive in my user model, and I define my own callback controller in the routes file:

devise_for :users, :controllers => { :omniauth_callbacks => 'user/authentications', :registrations => 'registrations' }

root :to => 'pages#home'

And I also tried adding this to the routes file with no luck:

get '/users/auth/:provider' => 'user/authentications#passthru'

Here is my authentications controller:

class AuthenticationsController < Devise::OmniauthCallbacksController
  def index
    @authentications = current_user.authentications if current_user
  end

  def facebook
    omniauth = request.env["omniauth.auth"]
    authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
    if authentication
      flash[:notice] = "Signed in successfully."
      sign_in_and_redirect(:user, authentication.user)
    elsif current_user
      current_user.authentications.create!(:provider => omniauth['provider'], :uid => omniauth['uid'])
      flash[:notice] = "Authentication successful."
      redirect_to authentications_url
    else
      user = User.new
      user.apply_omniauth(omniauth)
      if user.save
        flash[:notice] = "Signed in successfully."
        sign_in_and_redirect(:user, user)
      else
        session[:omniauth] = omniauth.except('extra')
        redirect_to new_user_registration_url
      end
    end
  end

  def passthru
    render :file => "#{Rails.root}/public/404.html", :status => 404, :layout => false
  end

  def destroy
    @authentication = current_user.authentications.find(params[:id])
    @authentication.destroy
    flash[:notice] = "Successfully destroyed authentication."
    redirect_to authentications_url
  end
end

And my Facebook log in link:

<%= link_to image_tag(‘/assets/facebook_32.png’), omniauth_authorize_path(resource_name, :facebook)%>

This all works great locally, but if I try to log in with my Facebook account when my app is deployed to Heroku, I get the following in my log and I’m directed to the 404 page:

2011-09-23T03:26:31+00:00 app[web.1]: ActionController::RoutingError (uninitiali
zed constant User::AuthenticationsController):

I tried resetting my database, but that didn’t help either.

Here are my routes from Heroku:

        new_user_session GET    /users/sign_in(.:format)               {:action=
>"new", :controller=>"devise/sessions"}
            user_session POST   /users/sign_in(.:format)               {:action=
>"create", :controller=>"devise/sessions"}
    destroy_user_session GET    /users/sign_out(.:format)              {:action=
>"destroy", :controller=>"devise/sessions"}
  user_omniauth_callback        /users/auth/:action/callback(.:format) {:action=
>/facebook/, :controller=>"user/authentications"}
           user_password POST   /users/password(.:format)              {:action=
>"create", :controller=>"devise/passwords"}
       new_user_password GET    /users/password/new(.:format)          {:action=
>"new", :controller=>"devise/passwords"}
      edit_user_password GET    /users/password/edit(.:format)         {:action=
>"edit", :controller=>"devise/passwords"}
                         PUT    /users/password(.:format)              {:action=
>"update", :controller=>"devise/passwords"}
cancel_user_registration GET    /users/cancel(.:format)                {:action=
>"cancel", :controller=>"registrations"}
       user_registration POST   /users(.:format)                       {:action=
>"create", :controller=>"registrations"}
   new_user_registration GET    /users/sign_up(.:format)               {:action=
>"new", :controller=>"registrations"}
  edit_user_registration GET    /users/edit(.:format)                  {:action=
>"edit", :controller=>"registrations"}
                         PUT    /users(.:format)                       {:action=
>"update", :controller=>"registrations"}
                         DELETE /users(.:format)                       {:action=
>"destroy", :controller=>"registrations"}
                    root        /                                      {:control
ler=>"pages", :action=>"home"}

Any help is greatly appreciated. Please let me know if you need any other info. I know it’s something small, but I feel like I’ve tried a thousand different things and nothing has worked.

  • 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-25T20:28:39+00:00Added an answer on May 25, 2026 at 8:28 pm

    I think, your authenicatine line should be using find_or_create.

    authentication = Authentication.find_or_create_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.