5 validates_presence_of :director
6 validates_presence_of :video_genre_id
7 validates_presence_of :video_media_id
10 VideoGenre.find_by_id(video_genre_id)
14 VideoMedia.find_by_id(video_media_id)
18 day_of_week = Time.now.to_date.wday
19 base_fee = VideoPolicy.find_by_day(day_of_week).fee
21 # Check for newrelease
22 newrelease_fee = newrelease ? VideoPolicy.find_by_day(8).fee : 0.00
24 return base_fee + newrelease_fee
28 # NOTE: a Date.wday will tell you the day of week (0-6, meaning Sunday-Saturday)
29 day_of_week = Time.now.to_date.wday
30 base_period = VideoPolicy.find_by_day(day_of_week).period
31 newrelease_period = newrelease ? VideoPolicy.find_by_day(8).period : 0
33 period = base_period + newrelease_period
34 return Time.now.advance(:days => period).to_date
39 errors.add(:video_genre_id, "does not exist in the database") if genre.nil?
40 errors.add(:video_media_id, "does not exist in the database") if media.nil?