2018-11-29 20:57:57 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class User < ApplicationRecord
|
|
|
|
devise(
|
2018-12-03 17:58:39 +00:00
|
|
|
:confirmable,
|
2018-11-29 20:57:57 +00:00
|
|
|
:database_authenticatable,
|
2018-12-03 20:19:41 +00:00
|
|
|
:lockable,
|
2018-12-04 02:28:16 +00:00
|
|
|
:omniauthable,
|
2018-12-03 20:03:01 +00:00
|
|
|
:recoverable,
|
2018-11-29 20:57:57 +00:00
|
|
|
:registerable,
|
|
|
|
:rememberable,
|
2018-12-04 02:12:07 +00:00
|
|
|
:timeoutable,
|
2018-11-29 20:57:57 +00:00
|
|
|
:trackable,
|
|
|
|
:validatable,
|
2018-12-04 02:28:16 +00:00
|
|
|
omniauth_providers: %i[github],
|
2018-11-29 20:57:57 +00:00
|
|
|
)
|
2018-12-02 02:50:10 +00:00
|
|
|
|
2019-03-26 00:56:31 +00:00
|
|
|
################
|
|
|
|
# Associations #
|
|
|
|
################
|
|
|
|
|
2018-12-02 02:50:10 +00:00
|
|
|
belongs_to :account
|
|
|
|
|
2018-12-04 03:08:33 +00:00
|
|
|
has_many :user_omniauths, dependent: :restrict_with_exception
|
|
|
|
|
2019-03-26 00:56:31 +00:00
|
|
|
###############
|
|
|
|
# Validations #
|
|
|
|
###############
|
|
|
|
|
2019-03-24 01:42:27 +00:00
|
|
|
validates :account, uniqueness: true
|
2018-12-02 02:50:10 +00:00
|
|
|
|
2019-03-26 00:56:31 +00:00
|
|
|
#############
|
|
|
|
# Callbacks #
|
|
|
|
#############
|
|
|
|
|
2018-12-02 02:50:10 +00:00
|
|
|
before_validation do
|
|
|
|
self.account ||= Account.new
|
|
|
|
end
|
2018-11-29 20:57:57 +00:00
|
|
|
end
|