OSDN Git Service

merge
[pettanr/pettanr.git] / app / models / author.rb
index 2341a9f..c598a8a 100644 (file)
@@ -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