|
|
@ -1,4 +1,14 @@
|
|
|
|
class Movie < ApplicationRecord
|
|
|
|
class Movie < ApplicationRecord
|
|
|
|
|
|
|
|
validates :title, :released_on, :duration, presence: true
|
|
|
|
|
|
|
|
validates :description, length: { minimum: 25 }
|
|
|
|
|
|
|
|
validates :total_gross, numericality: { greater_than_or_equal_to: 0 }
|
|
|
|
|
|
|
|
validates :image_file_name, format: {
|
|
|
|
|
|
|
|
with: /\w+\.(jpg|png)\z/i,
|
|
|
|
|
|
|
|
message: "must be a JPG or PNG image"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
RATINGS = %w(G PG PG-13 R X NC-17)
|
|
|
|
|
|
|
|
validates :rating, inclusion: { in: RATINGS }
|
|
|
|
|
|
|
|
|
|
|
|
def flop?
|
|
|
|
def flop?
|
|
|
|
total_gross.blank? || total_gross < 225_000_000
|
|
|
|
total_gross.blank? || total_gross < 225_000_000
|
|
|
|
end
|
|
|
|
end
|
|
|
|