Skip to content

Instantly share code, notes, and snippets.

@kaileeagray
Created August 23, 2016 15:07
Show Gist options
  • Save kaileeagray/21d073cf3e223df06fc4b0bbdfa8ce94 to your computer and use it in GitHub Desktop.
Save kaileeagray/21d073cf3e223df06fc4b0bbdfa8ce94 to your computer and use it in GitHub Desktop.
class User < ApplicationRecord
validates :email, :presence => true
validates :email, :uniqueness => true
has_secure_password
def self.find_or_create_by_omniauth(auth)
oauth_email = auth["info"]["email"] || auth["info"]["nickname"] || auth["info"]["name"]
self.where(:email => oauth_email).first_or_create do |user|
user.password = SecureRandom.hex
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment