OSDN Git Service

cc154ca1d57a712b1b99a4356f1fa5c621ef0d91
[pettanr/pettanr.git] / app / models / author.rb
1 class Author < ActiveRecord::Base
2   has_one :artist
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 :email, :password, :password_confirmation, :remember_me
11
12   before_save :ensure_authentication_token\r
13   before_save do |r|
14     r.name = 'no name' if r.name.blank?
15   end
16   
17  def artist?
18    Artist.find_by_author(self) != nil
19  end
20  
21 end