Sha256: bd90f705ad9897a7ffe521d81a2c6c2c74b7d2000f1093d13a91ee56e816c61c
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
class User < ApplicationRecord after_create :send_welcome_mail has_many :comments, dependent: :destroy has_one_attached :avatar def full_name "#{first_name} #{last_name}" end # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :trackable, :omniauthable, omniauth_providers: [:google_oauth2] def self.from_omniauth(access_token) user = User.find_by(email: access_token.info.email) unless user user = User.create( email: access_token.info.email, password: Devise.friendly_token[0,20] ) end user.first_name = access_token.info.first_name user.last_name = access_token.info.last_name user.image = access_token.info.image # user.uid = access_token.uid # user.provider = access_token.provider user.save user end private def send_welcome_mail UserMailer.with(user: self).welcome_email.deliver_now end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
blog_app-0.0.1 | lib/app/models/user.rb |