Sha256: bc89f56318cd3129a9a315ca62b3335f9cf5a698074370cb4c039431c38ccb16

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

module Optimacms
  class CmsAdminUser < ActiveRecord::Base
    self.table_name = 'cms_users'

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


    # search
    searchable_by_simple_filter

    ### validate
    validates_confirmation_of :password

    validates :password, :presence     => true,
              :confirmation => true,
              :length       => { :minimum => 6 },
              :if           => :should_validate_password? # only validate if password changed!

    def should_validate_password?
      x = new_record? || !password.blank?
      #if: Proc.new{|obj| obj.new_record? || !obj.<attribute>.blank? }
    end

    before_destroy :can_destroy?

    def can_destroy?
      !self.is_superadmin
    end


    ## properties

    def is_superadmin?
      self.is_superadmin
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
optimacms-0.3.23 app/models/optimacms/cms_admin_user.rb
optimacms-0.3.15 app/models/optimacms/cms_admin_user.rb
optimacms-0.3.12 app/models/optimacms/cms_admin_user.rb
optimacms-0.3.11 app/models/optimacms/cms_admin_user.rb
optimacms-0.2.26 app/models/optimacms/cms_admin_user.rb
optimacms-0.2.25 app/models/optimacms/cms_admin_user.rb
optimacms-0.2.24 app/models/optimacms/cms_admin_user.rb