From: Ira W. Snyder Date: Tue, 27 Nov 2007 00:23:10 +0000 (-0800) Subject: Fix validation of Games and Videos X-Git-Tag: turned-in~15 X-Git-Url: https://www.irasnyder.com/gitweb/?a=commitdiff_plain;h=08bd77ec5f61f7d1215c1a22e74e3fb2eb0b9f78;p=cs356-p2-videostore.git Fix validation of Games and Videos Signed-off-by: Ira W. Snyder --- diff --git a/app/models/game.rb b/app/models/game.rb index 55639a7..a2d324a 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -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 diff --git a/app/models/video.rb b/app/models/video.rb index 7739aeb..fd5d22f 100644 --- a/app/models/video.rb +++ b/app/models/video.rb @@ -38,7 +38,7 @@ class Video < Rentable protected def validate - errors.add(:video_genre, "does not exist in the database") if video_genre.nil? - errors.add(:video_media, "does not exist in the database") if video_media.nil? + errors.add(:video_genre_id, "does not exist in the database") if genre.nil? + errors.add(:video_media_id, "does not exist in the database") if media.nil? end end