I have the following code (which is not working as I would like)
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid) || auth.info.slice(:email)).first_or_initialize.tap do |user|
user.provider = auth.provider
user.uid = auth.uid
user.name = auth.info.name
user.email = auth.info.email
user.oauth_token = auth.credentials.token
user.oauth_expires_at = Time.at(auth.credentials.expires_at)
if user.password = ""
temp_pass = SecureRandom.urlsafe_base64
user.password = temp_pass
user.password_confirmation = temp_pass
end
user.save!
end
end
What I am trying to create is a activerecord where clause such as:
User.where("provider = ? AND uid = ? OR email = ?", "facebook", "1569037127","[email protected]")
The SQL that is generated when this code is executed does not include the OR statement, or any reference to the email field.
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."provider" = 'facebook' AND "users"."uid" = '100007760885613' ORDER BY "users"."id" ASC LIMIT 1
Any help with this would be fantastic...