X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=app%2Fmodels%2Fgame.rb;h=f2e627c765ab12e21bcc514aa5c2c7603dda42af;hb=e4597521e3a7365f86731f7d69643cb1067acb5e;hp=6c6b59be09b563ca2504fddb445ac6079220734b;hpb=bf5c679032a167a9eeb4aa16284cd5dd2426a12a;p=cs356-p2-videostore.git diff --git a/app/models/game.rb b/app/models/game.rb index 6c6b59b..f2e627c 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -1,7 +1,18 @@ class Game < Rentable + has_many :game_genres, :through => Gamegenre + has_many :gameplatforms, :through => Gameplatform + validates_presence_of :game_genre validates_presence_of :platform + def genre + return Gamegenre.find(game_genre).name + end + + def game_platform + return Gameplatform.find(platform).name + end + def calculated_price # FIXME: generate this based on day of week, newrelease day_of_week = Time.now.to_date.wday @@ -24,4 +35,12 @@ class Game < Rentable return Time.now.advance(:days => period).to_date end + def genre_name + Gamegenre.find_by_id(game_genre).name + end + + def platform_name + Gameplatform.find_by_id(platform).name + end + end