So I am trying to build omniauth into my webpapp:
Omni-Auth gets called from SessionsController
class SessionsController < ApplicationController
def create
auth = request.env["omniauth.auth"]
user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth)
cookies.permanent.signed[:user_id] = user.id
redirect_to assignment_path
end
end
And then users are added to the DB in the User model
class User < ActiveRecord::Base
def self.create_with_omniauth(auth)
create! do |user|
user.name = auth["user_info"]["name"]
user.picture = auth["user_info"]["profile_image_url"]
user.screen_name = auth["user_info"]["screen_name"]
user.provider = auth["provider"]
user.uid = auth["uid"]
end
end
end
The name, uid and provider get added to the DB but unfortunately the picture and screen_name do not get added to the DB.
Can any one help?
Problem solved.
I was accessing the hash using the wrong parameters.