OSDN Git Service

temp
[pettanr/pettanr.git] / app / models / story.rb
index 3d20165..88ce170 100644 (file)
@@ -1,5 +1,5 @@
 #ストーリー
-class Story < ActiveRecord::Base
+class Story < Pettanr::Item
   has_many :story_sheets
   belongs_to :comic
   
@@ -7,13 +7,21 @@ class Story < ActiveRecord::Base
   validates :title, :presence => true, :length => {:maximum => 100}
   validates :visible, :presence => true, :numericality => true, :inclusion => {:in => 0..1}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
-  before_validation :valid_encode
   
-  def valid_encode
-    ['title', 'description'].each do |a|
-      next if attributes[a] == nil
-      raise Pettanr::BadRequest unless attributes[a].valid_encoding?
-    end
+  def self.singular
+    'Story'
+  end
+  
+  def self.plural
+    'Stories'
+  end
+  
+  def self.owner_type
+    :author
+  end
+  
+  def self.valid_encode_columns
+    super.merge ['title', 'description']
   end
   
   def supply_default