Sha256: 7a7bdd7eab369fcfa105a1f389359d84049a43bb4542f5db06be29c82d92e640
Contents?: true
Size: 1.13 KB
Versions: 12
Compression:
Stored size: 1.13 KB
Contents
module Guts # User model class User < ActiveRecord::Base include TrackableConcern # Regex to test email against for validation VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :name, presence: true, length: { maximum: 50 } validates :email, presence: true, length: { maximum: 255 }, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false } validates :password, presence: true, length: { minimum: 6 }, allow_nil: true has_secure_password has_many :media, as: :filable, dependent: :destroy has_many :metafields, as: :fieldable, dependent: :destroy has_many :user_groups has_many :groups, through: :user_groups has_many :tracks, as: :object has_many :contents trackable :create, :update, :destroy, fields: [:name, :group_id] scope :in_group, -> (group) { includes(:groups).where(guts_groups: { id: group.id }) } # Setter override for email to downcase and strip email before database def email=(email) self[:email] = email.downcase.strip end end end
Version data entries
12 entries across 12 versions & 1 rubygems