app/controllers/sessions_controller.rb
#Create a new user if there is none through OmniAuth-Facebook, set session id and go to the users home page.
Create a new user if there is none through OmniAuth-Facebook, set session id and go to the users home page.
Create a new user if there is none through OmniAuth - Facebook set session id and go to the users home page .
def facebook_create
        @new_user = User.find_or_create_by(uid: auth['uid']) do |u|
            u.name = auth['info']['name']
            u.email = auth['info']['email']
            u.image = auth['info']['image']
            u.password = User.generic_password
        end
        @new_user.save
        session[:user_id] = @new_user.id  
        redirect_to home_path(@new_user)
    end
def facebook_create @new_user = User . find_or_create_by ( uid : auth [ 'uid' ] ) do | u | u . name = auth [ 'info' ] [ 'name' ] u . email = auth [ 'info' ] [ 'email' ] u . image = auth [ 'info' ] [ 'image' ] u . password = User . generic_password end @new_user . save session [ :user_id ] = @new_user . id redirect_to home_path ( @new_user ) end
Create a new user if there is none through OmniAuth-Facebook, set session id and go to the users home page.
Create a new user if there is none through OmniAuth - Facebook set session id and go to the users home page .