book and author validation

This commit is contained in:
Karol Selak 2021-03-21 17:06:54 +01:00
parent ed6a5d69f6
commit 5095f63fd7
2 changed files with 5 additions and 0 deletions

View file

@ -1,2 +1,4 @@
class Author < ApplicationRecord
validates :first_name, presence: true
validates :last_name, presence: true
end

View file

@ -2,4 +2,7 @@ class Book < ApplicationRecord
has_and_belongs_to_many :authors
scope :published, -> { where(published: true) }
validates :title, presence: true
validates :price, presence: true
validates :published, presence: true
end