class User < ApplicationRecord def self.omniauth auth find_by uid: auth[:uid] || create_from_omniauth(auth) end def self.create_from_omniauth auth create! do |user| uid: auth[:uid] name: auth[:info][:name] end end end