personal-book/app/models/book_author.rb

15 lines
405 B
Ruby
Raw Permalink Normal View History

class BookAuthor
include Mongoid::Document
include Mongoid::Timestamps
field :name, type: String, localize: true
field :email, type: String
field :should_destroy, type: Boolean
has_and_belongs_to_many :books
has_and_belongs_to_many :book_author_types
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/
validates :email, format: { with: VALID_EMAIL_REGEX }, allow_blank: true
end