books edition by admin
This commit is contained in:
parent
5095f63fd7
commit
e36cc36947
10 changed files with 119 additions and 20 deletions
|
@ -4,5 +4,4 @@ class Book < ApplicationRecord
|
|||
scope :published, -> { where(published: true) }
|
||||
validates :title, presence: true
|
||||
validates :price, presence: true
|
||||
validates :published, presence: true
|
||||
end
|
||||
|
|
|
@ -5,5 +5,9 @@ class User < ApplicationRecord
|
|||
|
||||
validates :email, presence: true, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
|
||||
validates :role, presence: true
|
||||
validates :password, presence: true, length: { minimum: 8 }
|
||||
validates :password, {
|
||||
presence: true,
|
||||
length: { minimum: 8 },
|
||||
if: lambda{ new_record? || !password.nil? }
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue