admin_user.rb 742 B

123456789101112131415161718192021
  1. class AdminUser < ActiveRecord::Base
  2. # Setup accessible (or protected) attributes for your model
  3. attr_accessible :email, :password, :password_confirmation, :remember_me
  4. # Include default devise modules. Others available are:
  5. # :token_authenticatable, :confirmable,
  6. # :lockable, :timeoutable and :omniauthable
  7. devise :database_authenticatable,
  8. :recoverable, :rememberable, :trackable, :validatable
  9. validates :email,
  10. :presence => true,
  11. :format => { :with => /\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\z/, :message => "Must be of E-Mail address format" }
  12. after_create { |admin| admin.send_reset_password_instructions }
  13. def password_required?
  14. new_record? ? false : super
  15. end
  16. end