0

I'm trying to do a simple omniauth call with facebook. Everything works fine if I capture the request hash like this:

def facebook
    user = User.from_facebook(request.env["omniauth.auth"])
    if user.persisted?
      ...
    else
      ...
    end
  end

But if I try to save the request hash in a variable, I get request = nil. e.g.:

def facebook
  omni_request = request.env["omniauth.auth"]
  user = User.from_facebook(omni_request)
  if user.persisted?
    ...
  else
    ...
  end
end

The above example blows up because request is nil, and I can't call env on something that is nil.

Does anyone have any idea why request would be nil when called outside of the from_facebook class method?

Arel
  • 3,888
  • 6
  • 37
  • 91

1 Answers1

2

the third line should be : user = User.from_facebook(omni_request) ?

marmot_cj
  • 36
  • 2
  • 1
    So, the problem was that I called my variable request in my actual code, which was overwriting the request ... So technically you were right, so I'll give it to you. – Arel Jan 16 '15 at 02:12