Sha256: 331e6e648dd5f1b21622c81105ee5d27c6c451c0e9b70cc4650a25172fc5b6f9

Contents?: true

Size: 840 Bytes

Versions: 7

Compression:

Stored size: 840 Bytes

Contents

module LatoCore
  class Superuser < ActiveRecord::Base

    include Superuser::EntityHelpers

    has_secure_password

    # Validations:

    validates :name, presence: true, length: { maximum: 50 }

    validates :surname, presence: true, length: { maximum: 50 }

    validates :username, presence: true, length: { minimum: 4, maximum: 50 },
    uniqueness: { case_sensitive: false }

    validates :email, presence: true, length: { maximum: 255 },
    format: { with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i },
    uniqueness: { case_sensitive: false }

    validates :password, presence: true, length: { minimum: 6, maximum: 50 },  on: :create

    validates :permission, presence: true, inclusion: { in: CORE_SUPERUSERS_PERMISSIONS }

    # Callbacks:

    before_save do
      username.downcase!
      email.downcase!
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lato_core-2.2.2 app/models/lato_core/superuser.rb
lato_core-2.2.0 app/models/lato_core/superuser.rb
lato_core-2.1.4 app/models/lato_core/superuser.rb
lato_core-2.1.3 app/models/lato_core/superuser.rb
lato_core-2.1.2 app/models/lato_core/superuser.rb
lato_core-2.1.1 app/models/lato_core/superuser.rb
lato_core-2.1 app/models/lato_core/superuser.rb