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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:59:20+00:00 2026-06-06T17:59:20+00:00

How do one handle facebook user that dont provide some value? I am using

  • 0

How do one handle facebook user that dont provide some value? I am using the koala gem and omniauth.

I get the following error:

NoMethodError in SessionsController#create
undefined method `[]' for nil:NilClass

app/models/user.rb:14:in `block in from_omniauth'
app/models/user.rb:5:in `tap'
app/models/user.rb:5:in `from_omniauth'
app/controllers/sessions_controller.rb:3:in `create'

And I get this error because the facebook user my app is trying to autenticate dosent have some data values that my app want, like location, education history etc..

A new user process, beging in the SessionsController:

class SessionsController < ApplicationController
  def create
    user = User.from_omniauth(env['omniauth.auth'])
    session[:user_id] = user.id
    redirect_to root_url, notice: "Signed in!"
  end
end

Then in the user model:

def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
  user.provider = auth["provider"]
  user.uid = auth["uid"]
  user.name = auth["info"]["name"] unless auth["info"].blank?
  user.first_name = auth["info"]["first_name"] unless auth["info"].blank?
  user.last_name = auth["info"]["last_name"] unless auth["info"].blank?
  user.image = auth["info"]["image"] unless auth["info"].blank?
  user.email = auth["info"]["email"] unless auth["info"].blank?
  user.gender = auth["extra"]["raw_info"]["gender"] if (!auth["extra"].blank? && !auth["extra"]["raw_info"].blank?)
  user.location = auth["extra"]["raw_info"]["location"]["name"] if (!auth["extra"].blank? && !auth["extra"]["raw_info"].blank? && !auth["extra"]["raw_info"]["location"].blank?)          
  user.token = auth["credentials"]["token"] unless auth["credentials"].blank?


    # highschool data
    user.highschool_name = auth["extra"]["raw_info"]["education"][0]["school"]["name"] if (!auth["extra"].blank? && !auth["extra"]["raw_info"]["education"][0]["school"].blank?)
    user.highschool_year = auth["extra"]["raw_info"]["education"][0]["year"]["name"] if (!auth["extra"].blank? && !auth["extra"]["raw_info"]["education"][0]["year"].blank?)
    # graduate school data
    user.graduateschool_name = auth["extra"]["raw_info"]["education"][1]["school"]["name"] if (!auth["extra"].blank? && !auth["extra"]["raw_info"]["education"][1]["school"].blank?)
    user.graduateschool_year = auth["extra"]["raw_info"]["education"][1]["year"]["name"] if (!auth["extra"].blank? && !auth["extra"]["raw_info"]["education"][1]["year"].blank?)

  user.add_friends
  user.save!
      user
 end 
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-06-06T17:59:23+00:00Added an answer on June 6, 2026 at 5:59 pm

    the error is in line 14 for you User model file like for example if auth["credentials"] is nil auth["credentials"]["token"] will give the same error you got.

    Put checks in line when you assigning the values, e.g., user.token = auth["credentials"]["token"] unless auth["credentials"].blank?

    UPDATE

      user.first_name = auth["info"]["first_name"] unless auth["info"].blank?
      user.last_name = auth["info"]["last_name"] unless auth["info"].blank?
      user.image = auth["info"]["image"] unless auth["info"].blank?
      user.email = auth["info"]["email"] unless auth["info"].blank?
      user.gender = auth["extra"]["raw_info"]["gender"] if (!auth["extra"].blank? && !auth["extra"]["raw_info"].blank?)
      user.location = auth["extra"]["raw_info"]["location"]["name"] if (!auth["extra"].blank? && !auth["extra"]["raw_info"].blank? && !auth["extra"]["raw_info"]["location"].blank?)
      user.token = auth["credentials"]["token"] unless auth["credentials"].blank?
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It is my understanding that one can handle events through Swing by adding a
Some one please tell me how to handle RunTimeExceptions in grails version1.1 .I have
I'm making a website that tend to handle all the request in one page
Some social games on Facebook let user publish a link to their feed to
How does one handle image downloads in a mobi site - using jquery mobile
I have a Facebook Connect app that I monetize using Google AdSense. I want
How can one handle email related communications pragmatically in Erlang/OTP? Using bash, python or
Looking at the Facebook iOS app, one can see that when in the feed
How does one handle ties when ranking results in a mysql query? I've simplified
Why does IDLE handle one symbol correctly but not another? >>> e = '€'

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.