Sha256: 3535cb4807f137ad520ea7594902369ff16b676cafe73dc3d8ff9470b0a6acce
Contents?: true
Size: 835 Bytes
Versions: 3
Compression:
Stored size: 835 Bytes
Contents
# frozen_string_literal: true module Admin class User < ApplicationRecord include Koi::Model::Archivable def self.model_name ActiveModel::Name.new(self, nil, "Admin") end has_secure_password :password has_many :credentials, inverse_of: :admin, class_name: "Admin::Credential", dependent: :destroy validates :name, :email, presence: true validates :email, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP } scope :alphabetical, -> { order(name: :asc) } if "PgSearch::Model".safe_constantize include PgSearch::Model pg_search_scope :admin_search, against: %i[email name], using: { tsearch: { prefix: true } } else scope :admin_search, ->(query) do where("email LIKE :query OR name LIKE :query", query: "%#{query}%") end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
katalyst-koi-4.5.0 | app/models/admin/user.rb |
katalyst-koi-4.5.0.beta.2 | app/models/admin/user.rb |
katalyst-koi-4.5.0.beta.1 | app/models/admin/user.rb |