Add media MVC
[cs356-p2-videostore.git] / app / models / video.rb
index 4ecf31b..411c978 100644 (file)
@@ -1,6 +1,14 @@
-class Video < ActiveRecord::Base
-  belongs_to :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
+
+  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