projects
/
cs356-p2-videostore.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Lots of stuff, I got too tired to keep perfect revision history
[cs356-p2-videostore.git]
/
app
/
models
/
video.rb
diff --git
a/app/models/video.rb
b/app/models/video.rb
index
52344e1
..
8ca3901
100644
(file)
--- a/
app/models/video.rb
+++ b/
app/models/video.rb
@@
-1,13
+1,20
@@
class Video < Rentable
has_many :video_genres
class Video < Rentable
has_many :video_genres
- has_many :medias
+ has_many :
video_
medias
validates_presence_of :director
validates_presence_of :director
- validates_presence_of :video_genre
- validates_presence_of :media
+ validates_presence_of :video_genre_id
+ validates_presence_of :video_media_id
+
+ def genre
+ VideoGenre.find_by_id(video_genre_id)
+ end
+
+ def media
+ VideoMedia.find_by_id(video_media_id)
+ end
def calculated_price
def calculated_price
- # FIXME: generate this based on day of week, newrelease
day_of_week = Time.now.to_date.wday
base_fee = VideoPolicy.find_by_day(day_of_week).fee
day_of_week = Time.now.to_date.wday
base_fee = VideoPolicy.find_by_day(day_of_week).fee
@@
-18,7
+25,6
@@
class Video < Rentable
end
def due_date
end
def due_date
- # FIXME: generate this based on the day of week, newrelease
# NOTE: a Date.wday will tell you the day of week (0-6, meaning Sunday-Saturday)
day_of_week = Time.now.to_date.wday
base_period = VideoPolicy.find_by_day(day_of_week).period
# NOTE: a Date.wday will tell you the day of week (0-6, meaning Sunday-Saturday)
day_of_week = Time.now.to_date.wday
base_period = VideoPolicy.find_by_day(day_of_week).period
@@
-30,7
+36,7
@@
class Video < Rentable
protected
def validate
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?
+ 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
end
end