Closed vanderleipinto closed 9 months ago
Add gem 'isbn' into the project. In the file Gemfile:
# Validator to ISBN gem 'isbn', '~> 2.0', '>= 2.0.11'
bundle
class Book < ApplicationRecord belongs_to :author has_and_belongs_to_many :assemblies validates :name, presence: true validate :isbn, :isbn_valid private def isbn_valid errors.add :isbn, "invalid isbn." unless ISBN.valid?(isbn) end end
OBS: The attribute name will be changed further to title.
Add Gem
Add gem 'isbn' into the project. In the file Gemfile:
Runs bundle to install the Gem
bundle
Add validates into the Book model including the callback validator '':
OBS: The attribute name will be changed further to title.