Guest User

book_author.rb

a guest
May 6th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. # == Schema Information
  2. #
  3. # Table name: book_authors
  4. #
  5. # id :bigint not null, primary key
  6. # book_id :bigint
  7. # author_name :string
  8. # created_at :datetime not null
  9. # updated_at :datetime not null
  10. #
  11. class BookAuthor < ApplicationRecord
  12.  
  13. belongs_to :book
  14.  
  15. validates :author_name, presence: true, uniqueness: { scope: :book_id,
  16. message: 'already added to this book'}
  17. end
Add Comment
Please, Sign In to add comment