OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / models / author.rb
index cc154ca..c598a8a 100644 (file)
@@ -1,21 +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 :email, :password, :password_confirmation, :remember_me
-
-  before_save :ensure_authentication_token\r
-  before_save do |r|
-    r.name = 'no name' if r.name.blank?
+  validates :name, :presence => true, :length => {:maximum => 30}
+  validates :user_id, :numericality => true, :existence => {:both => false}
+  
+  scope :find_index, -> do
+    self
+  end
+  
+  def supply_default
+    self.name = 'no name' if self.name.blank?
+    self.user_id = nil
+  end
+  
+  def self.show_opt
+    {:include => {:user => {:artist => {}}} }
   end
   
- def artist?
-   Artist.find_by_author(self) != nil
- end
 end