X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=app%2Fmodels%2Fauthor.rb;h=c598a8a694e4171b5ab3cfac641d1d9c7c50bc60;hb=0ead3a286b925e86845cf8211982a7985e522813;hp=2341a9f3b3b0c388b033a1c46a135f5bb5021095;hpb=3bb159eda799aa3c5f19edb73ca9e44fbb6988db;p=pettanr%2Fpettanr.git diff --git a/app/models/author.rb b/app/models/author.rb index 2341a9f3..c598a8a6 100644 --- a/app/models/author.rb +++ b/app/models/author.rb @@ -1,35 +1,25 @@ -class Author < ActiveRecord::Base - has_one :artist +class Author < Peta::Owner + load_manifest + belongs_to :user + has_many :scrolls + has_many :comics + has_many :sheets + has_many :panels - # Include default devise modules. Others available are: - # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable - devise :database_authenticatable, :registerable, - :recoverable, :rememberable, :trackable, :token_authenticatable, :validatable#, :confirmable - - # Setup accessible (or protected) attributes for your model - attr_accessible :id, :name, :password, :password_confirmation, :remember_me #, :email - - before_save do |r| - r.name = 'no name' if r.name.blank? - end - - def artist? - Artist.find_by_author(self) != nil - end + validates :name, :presence => true, :length => {:maximum => 30} + validates :user_id, :numericality => true, :existence => {:both => false} - def create_token - self.ensure_authentication_token - self.save + scope :find_index, -> do + self end - def delete_token - self.authentication_token = nil - self.save + def supply_default + self.name = 'no name' if self.name.blank? + self.user_id = nil end - def step2 n - self.name = n - self.save + def self.show_opt + {:include => {:user => {:artist => {}}} } end end