Sha256: 5b1173e020a565605ea70ae26e0efcf66f85edda69dbc563205b5fef9a3ee507

Contents?: true

Size: 1.94 KB

Versions: 6

Compression:

Stored size: 1.94 KB

Contents

# == Schema Information
#
# Table name: users
#
#  id                     :bigint           not null, primary key
#  confirmation_sent_at   :datetime
#  confirmation_token     :string
#  confirmed_at           :datetime
#  current_sign_in_at     :datetime
#  current_sign_in_ip     :string
#  developer              :boolean          default(FALSE), not null
#  discarded_at           :datetime
#  email                  :string           default(""), not null
#  encrypted_password     :string           default(""), not null
#  failed_attempts        :integer          default(0), not null
#  last_sign_in_at        :datetime
#  last_sign_in_ip        :string
#  locked_at              :datetime
#  remember_created_at    :datetime
#  reset_password_sent_at :datetime
#  reset_password_token   :string
#  sign_in_count          :integer          default(0), not null
#  unconfirmed_email      :string
#  unlock_token           :string
#  created_at             :datetime         not null
#  updated_at             :datetime         not null
#
# Indexes
#
#  index_users_on_confirmation_token    (confirmation_token) UNIQUE
#  index_users_on_email                 (email) UNIQUE
#  index_users_on_reset_password_token  (reset_password_token) UNIQUE
#  index_users_on_unlock_token          (unlock_token) UNIQUE
#
class User < ApplicationRecord
  # ApplicationRecord should be defined on Application

  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable,
         :confirmable, :lockable, :timeoutable, :trackable

  audited
  include Discard::Model

  has_many :user_accounts
  has_many :accounts, through: :user_accounts

  validates :email, presence: true

  scope :query, ->(param) { where('email ILIKE ?', "%#{param}%") }

  def to_s
    email
  end

  def current_account
    accounts.first
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pg_rails-7.0.8.pre.alpha.9 pg_engine/app/models/user.rb
pg_rails-7.0.8.pre.alpha.8 pg_engine/app/models/user.rb
pg_rails-7.0.8.pre.alpha.7 pg_engine/app/models/user.rb
pg_rails-7.0.8.pre.alpha.6 pg_engine/app/models/user.rb
pg_rails-7.0.8.pre.alpha pg_engine/app/models/user.rb
pg_rails-7.0.7 pg_engine/app/models/user.rb