book and author validation
This commit is contained in:
parent
ed6a5d69f6
commit
5095f63fd7
2 changed files with 5 additions and 0 deletions
|
@ -1,2 +1,4 @@
|
|||
class Author < ApplicationRecord
|
||||
validates :first_name, presence: true
|
||||
validates :last_name, presence: true
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue