OSDN Git Service

replace codes
[pettanr/pettanr.git] / app / models / admin.rb
1 class Admin < ActiveRecord::Base
2   # Include default devise modules. Others available are:
3   # , :encryptable, :lockable, :timeoutable and :omniauthable, :confirmable
4   devise :database_authenticatable, :registerable,
5          :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable
6
7   # Setup accessible (or protected) attributes for your model
8   attr_accessible :email, :password, :password_confirmation, :remember_me
9   before_save :ensure_authentication_token\r
10   
11   def active_for_authentication?\r
12     super && (self.approve == 1)\r
13   end
14
15   def self.start(email, passwd)
16     a = Admin.create! :email => email, :password => passwd, :password_confirmation => passwd
17     a.approve = 1
18     a.save!
19   end
20   
21 end