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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:40:24+00:00 2026-06-16T05:40:24+00:00

I am using omniauth to let users sign in with Facebook and Twitter accounts

  • 0

I am using omniauth to let users sign in with Facebook and Twitter accounts in a Ruby on Rails application. As Twitter request.env["omniauth.auth"] does not give the account’s email I construct it (the email cannot be NULL in the database). I have this piece of code:

if params[:provider] == 'facebook'
              email = omniauth[:info]["email"]
elsif params[:provider] == 'twitter'
              email = omniauth[:info]["name"] + '@example.com'
end
user = User.new(:email => email)

If I sign in with Facebook account it works perfect. But if I try with Twitter account the applicacion gives me this error:

SQLite3::ConstraintException: users.email may not be NULL [SQL query]

I checked if the email was NULL several times in case it was badly constructed or something, but is not NULL. omniauth-twitter and omniauth-facebook gems are installed.
Does anyone know why?
Let me know if you need more code or information.

  • 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-16T05:40:25+00:00Added an answer on June 16, 2026 at 5:40 am

    I don’t like any of theses approaches to be honest. A name isn’t a unique constraint and a Twitter user can change his nickname at any time. What would happen if a user changed his nickname? Would he no longer be able to access his account? And what if another person changed his nickname to the now available nickname? Would he be able to access the other user’s account?

    Two better solutions would be either:

    1. Follow Ryan Bates’s approach and redirect the user to a form where he can type his email. Or

    2. Override Devise’s method email_required?. Something like:

      # user.rb
      def email_required?
        authentications.empty?
      end
      

      This way you wouldn’t introduce an extra step into the login process.

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

Sidebar

Related Questions

i have authenticated users using devise and omniauth facebook gem in my rails 3.2
I am developing a rails 3.2 application and am authenticating using omniauth-facebook. This part
I have Ruby on Rails site. Users are allowed to login using their Facebook
I'm using OmniAuth + Devise to allow users to register using Facebook/Twitter/Gowalla/etc attached to
I am using Omniauth in my Rails project, and I'd like to hide /auth/facebook
I am using omniauth to register multiple user accounts from facebook, twitter and tumblr.
I'm using omniauth to implement twitter authentication in my application. I have facebook authentication
Trying to let users sign in / sign up with Twitter and Facebook. Twitter
I'm developing a Rails 3.0 application and am using OmniAuth + Identity for authentication
Using Omniauth version 1.0.2, currently when I call env[omniauth.auth][info][image] to get the image for

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.