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] = 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
             flash.now[:error] = 'Invalid email/password combination'
             render 'new'


Posted via http://www.ruby-forum.com/.

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0e528fca62afa38d4a6bdaa51dc272f2%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
postedDec 21, '13 at 2:19p
activeDec 21, '13 at 2:19p

1 user in discussion

Monty Lennie: 1 post



site design / logo © 2022 Grokbase