Complete Lesson 22

This commit is contained in:
Simon Quigley 2023-09-26 12:13:37 -05:00
parent 1a8d2c3e96
commit 71220cd85f
2 changed files with 6 additions and 0 deletions

View File

@ -9,6 +9,8 @@ class Movie < ApplicationRecord
RATINGS = %w(G PG PG-13 R X NC-17)
validates :rating, inclusion: { in: RATINGS }
has_many :reviews, dependent: :destroy
def flop?
total_gross.blank? || total_gross < 225_000_000
end

View File

@ -1,3 +1,7 @@
class Review < ApplicationRecord
belongs_to :movie
validates :name, presence: true
validates :comment, length: { minimum: 4 }
validates :stars, numericality: { greater_than_or_equal_to: 1, less_than_or_equal_to: 5 }
end