RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: dcdieci
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...
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.
auth = request.env["omniauth.auth"]
authentication = Authentication.find_or_create_by_provider_and_uid(auth['provider'], auth['uid'])
flash[:notice] = "Signed in successfully."
flash[:notice] = "auth successfull"