Sha256: f8513bb0a45ce04a9f63afec868e71c9a5b8df3f9e8e7848fc8340dad4b9deff

Contents?: true

Size: 451 Bytes

Versions: 9

Compression:

Stored size: 451 Bytes

Contents

class <%= class_name %> < ApplicationRecord
  has_secure_password :password
  has_secure_token :session_token

  validates :email, presence: true, uniqueness: true
  validates :email, format: { with: /\A[^@\s]+@[^@\s]+\z/ }
  validates_length_of :password, minimum: 8, allow_blank: true

  before_validation { self.email = email.downcase.strip }

  def as_json(options)
    super(options.merge(except: [:password_digest, :session_token]))
  end  
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
authentication-zero-0.0.14 lib/generators/authentication/templates/models/resource.rb.tt
authentication-zero-0.0.13 lib/generators/authentication/templates/models/resource.rb.tt
authentication-zero-0.0.12 lib/generators/authentication/templates/models/resource.rb.tt
authentication-zero-0.0.11 lib/generators/authentication/templates/models/resource.rb.tt
authentication-zero-0.0.10 lib/generators/authentication/templates/models/resource.rb.tt
authentication-zero-0.0.9 lib/generators/authentication/templates/models/resource.rb.tt
authentication-zero-0.0.8 lib/generators/authentication/templates/models/resource.rb.tt
authentication-zero-0.0.7 lib/generators/authentication/templates/models/resource.rb.tt
authentication-zero-0.0.6 lib/generators/authentication/templates/models/resource.rb.tt