Please read for an updated status on RailsCasts:
Learn more or hide this
GitHub User: mamadoutoure
How can the else case here would not fail, if we dont find and authentication with the provided params, and as there is no logged in user in this case so the current_user is Nil, so it should fail with Nil class exception when trying to call current_user.authentications.create(....)
omniauth = request.env["omniauth.auth"]
authentication = Authentication.find_by_provder_and_uid(omniauth['provider'], omniauth['uid'])
flash[:notice] = "Signed in successfully."
current_user.authentications.create(:provider => omniauth['provider'], :uid => omniauth['uid'])
flash[:notice] = "Authentication successful."