Complete Lesson 22
This commit is contained in:
parent
1a8d2c3e96
commit
71220cd85f
@ -9,6 +9,8 @@ class Movie < ApplicationRecord
|
|||||||
RATINGS = %w(G PG PG-13 R X NC-17)
|
RATINGS = %w(G PG PG-13 R X NC-17)
|
||||||
validates :rating, inclusion: { in: RATINGS }
|
validates :rating, inclusion: { in: RATINGS }
|
||||||
|
|
||||||
|
has_many :reviews, dependent: :destroy
|
||||||
|
|
||||||
def flop?
|
def flop?
|
||||||
total_gross.blank? || total_gross < 225_000_000
|
total_gross.blank? || total_gross < 225_000_000
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
class Review < ApplicationRecord
|
class Review < ApplicationRecord
|
||||||
belongs_to :movie
|
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user