Sha256: 7ec7d1927d470fb6a2f0c6c085931697bb7f49ad35681a679d66cb5fbdcedca0

Contents?: true

Size: 1021 Bytes

Versions: 1

Compression:

Stored size: 1021 Bytes

Contents

module RaffleV1
  class Admin < ActiveRecord::Base
    # Include default devise modules. Others available are:
    # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
    devise :database_authenticatable, #:registerable,
           :recoverable, :rememberable, :trackable, :validatable,
           :token_authenticatable, :lockable

    # Setup accessible (or protected) attributes for your model
    attr_accessible :email, :password, :password_confirmation, :remember_me, :admin_types, :program_ids
    default_scope where(:deleted_at => nil)

    has_and_belongs_to_many :programs

    def has_type admin_type
      if self.admin_types.present?
        self.admin_types.split(",").include?(admin_type)
      else
        false
      end
    end

    def self.admin_types
      [
        ["Admin", "admin"],
        ["Service", "service"]
      ]
    end

      def password_required?
        !persisted? || !password.nil? || !password_confirmation.nil?
      end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
raffle_v1-0.0.5 app/models/raffle_v1/admin.rb