Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

dcdieci's Profile

GitHub User: dcdieci

Comments by

Avatar

Hi again,

so my assumption was that the relation from authentication does not exist.
I added the following line in authentications controller
if authentication && authentication.user.present?

which seems to solve the problem...

Avatar

hi,

I was following both omniauth episodes in order to get my app running with twitter authorization.
Unfortunately I am stuck when i call /auth/twitter .
I get redirect to my page to the create action in the AuthenticationsController
the weird thing ist that authentication.user is nil when in try to call sign_in_and_redirect

My validations model contains the belongs_to :user relation, but apparently it can not find the associated user.

Any help would be appreciated.
Thanks in advance.
Philip

def create
auth = request.env["omniauth.auth"]
authentication = Authentication.find_or_create_by_provider_and_uid(auth['provider'], auth['uid'])
if authentication
flash[:notice] = "Signed in successfully."
puts authentication
puts authentication.user
sign_in_and_redirect(:user, authentication.user)
else
current_user.authentications.find_or_create_by_provider_and_uid(auth['provider'], auth['uid'])
flash[:notice] = "auth successfull"
redirect_to authentications_url
end
end