The code powering m.abunchtell.com https://m.abunchtell.com
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

123456789101112131415161718192021222324
  1. # frozen_string_literal: true
  2. class User < ApplicationRecord
  3. include Settings::Extend
  4. devise :registerable, :recoverable,
  5. :rememberable, :trackable, :validatable, :confirmable,
  6. :two_factor_authenticatable, otp_secret_encryption_key: ENV['OTP_SECRET']
  7. belongs_to :account, inverse_of: :user
  8. accepts_nested_attributes_for :account
  9. validates :account, presence: true
  10. validates :locale, inclusion: I18n.available_locales.map(&:to_s), unless: 'locale.nil?'
  11. validates :email, email: true
  12. scope :prolific, -> { joins('inner join statuses on statuses.account_id = users.account_id').select('users.*, count(statuses.id) as statuses_count').group('users.id').order('statuses_count desc') }
  13. scope :recent, -> { order('id desc') }
  14. scope :admins, -> { where(admin: true) }
  15. def send_devise_notification(notification, *args)
  16. devise_mailer.send(notification, self, *args).deliver_later
  17. end
  18. end