mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
upto 3.7
This commit is contained in:
@@ -6,8 +6,15 @@ class Brewery < ApplicationRecord
|
||||
|
||||
validates :name, presence: true
|
||||
validates :year, numericality: { greater_than_or_equal_to: 1040,
|
||||
less_than_or_equal_to: 2023,
|
||||
only_integer: true }
|
||||
validate :creation_year_not_in_future
|
||||
|
||||
def creation_year_not_in_future
|
||||
if year > Time.now.year
|
||||
errors.add :year, "cannot be in the future"
|
||||
end
|
||||
end
|
||||
|
||||
def print_report
|
||||
puts name
|
||||
puts "established at year #{year}"
|
||||
|
||||
Reference in New Issue
Block a user