Fix validation of Games and Videos
[cs356-p2-videostore.git] / app / models / game.rb
index 55639a7..a2d324a 100644 (file)
@@ -35,4 +35,10 @@ class Game < Rentable
     return Time.now.advance(:days => period).to_date
   end
 
+  protected
+  def validate
+    errors.add(:game_genre_id, "does not exist in the database") if genre.nil?
+    errors.add(:game_platform_id, "does not exist in the database") if platform.nil?
+  end
+
 end