Add list of just-purchased items (this transaction) to the purchase view
[cs356-p2-videostore.git] / app / models / video.rb
index 2ab598d..6f75a26 100644 (file)
@@ -1,6 +1,24 @@
-class Video < ActiveRecord::Base
-  has_one :rentable
+class Video < Rentable
+  has_many :video_genres
+  has_many :medias
 
   validates_presence_of :director
-  validates_presence_of :genre
+  validates_presence_of :video_genre
+  validates_presence_of :media
+
+  def calculated_price
+    # FIXME: generate this based on day of week, newrelase
+    return 11
+  end
+
+  def due_date
+    # FIXME: generate this based on the day of week, newrelease
+    return Time.now.advance(:days => 2).to_date
+  end
+
+  protected
+  def validate
+    errors.add(:video_genre, "does not exist in the database") if video_genre.nil?
+    errors.add(:media, "does not exist in the database") if media.nil?
+  end
 end