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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:34:42+00:00 2026-05-31T21:34:42+00:00

I am working on a rails app that allows users to log in via

  • 0

I am working on a rails app that allows users to log in via facebook/twitter/linkedin using omniauth. So far, users are able to sign up and create an account using the authentications, but they must pass validations and are therefore forwarded to a signup page where they must enter a valid name, username, and email. I want these fields to be already filled out if possible using the request.env[“omniauth.auth”] hash.

Here is my code:

authentications_controller.rb

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

registrations_controller.rb:

def build_resource(*args)
  super
  if session[:omniauth]
    @user.apply_omniauth(session[:omniauth])
    @user.valid?
  end
 end

user.rb:

def apply_omniauth(omniauth)
  self.name = omniauth['user_info']['name'] if name.blank?
  self.email = omniauth['user_info']['email'] if email.blank?
  authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])
end

The line:

self.email = omniauth['user_info']['email'] if email.blank?

results in this NoMethodError:

undefined method `[]' for nil:NilClass

The session[:omniauth] is being passed from the registrations controller to omniauth in the apply_omniauth method. How do I access the name and email in this session?

Thanks

  • 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-31T21:34:44+00:00Added an answer on May 31, 2026 at 9:34 pm
    1. Quick answer:

      omniauth.info.email # which is the same as omniauth['info']['email']
      
    2. Explanatory answer:

      Put this as the first line of your callback controller:

      render :text => "<pre>" + env["omniauth.auth"].to_yaml and return    
      

      Now try to login and you’ll be able to take a good look at the hash of nested hashes returned.

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

Sidebar

Related Questions

I have a rails app I am working on that allows users to create
I'm working on a Rails 3 app that allows users to follow movies by
I'm working on creating a Rails app that allows users to set availability Sunday
I am working on a Rails app that allows you to create a configuration
I'm working on a Rails app that existing users can invite additional members to
I'm working on a rails app that has a whole bunch of before filters
I'm working on a Rails app that sends data through a form. I want
I'm working on a Rails app that will contain information on a bunch of
I've been working on a rails app that uses the restful authentication plugin. It
We're working on a Ruby on Rails app that needs to take advantage of

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.