Complete Lesson 22

main
Simon Quigley 8 months ago
parent 1a8d2c3e96
commit 71220cd85f

@ -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

@ -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

Loading…
Cancel
Save