Forum: Ruby on Rails Omniauth facebook sessions controller create action integration

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
C3d8e91eed9e04d6a42c2f1a6fdc55fd?d=identicon&s=25 Monty Lennie (mlennie)
on 2013-12-21 15:19
I have just finished the Michael Hartl tutorial. I am trying to
implement omniauth-facebook to sign-up and sign-in users. I am having
trouble creating the master variable to use in the create action in the
sessions controller. My assumption is that I should put in an if else
statement to see if the master is either signing on through facebook or
through the default form? Or should I use and or statement:

(master = Master.find_by(email: params[:session][:email].downcase) ||
Master.from_omniauth(env["omniauth.auth"])) ?

Here is the omniauth-facebook sessons controller create action code:

def create
    user = User.from_omniauth(env["omniauth.auth"])
    session[:user_id] =
    redirect_to root_url

And here is my current sessions controller create action code:

class SessionsController < ApplicationController

    def new

    def create
        master = Master.find_by(email:
        if master && master.authenticate(params[:session][:password])
            sign_in master
            redirect_back_or master
  [:error] = 'Invalid email/password combination'
            render 'new'

This topic is locked and can not be replied to.