OSDN Git Service

user check
[pettanr/pettanr.git] / app / models / user.rb
1 class User < ActiveRecord::Base
2   has_one :author
3   
4   # Include default devise modules. Others available are:
5   # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
6   devise :database_authenticatable, :registerable,
7          :recoverable, :rememberable, :trackable, :token_authenticatable, :validatable#, :confirmable
8
9   # Setup accessible (or protected) attributes for your model
10   attr_accessible :id, :name, :password, :password_confirmation, :remember_me , :email
11
12   before_create do |r|
13     r.build_author :name => 'no name'
14   end
15   
16   def create_token
17     self.ensure_authentication_token
18     self.save
19   end
20   
21   def delete_token
22     self.authentication_token = nil
23     self.save
24   end
25   
26 end