orbit-basic/app/models/user/co_author.rb

20 lines
467 B
Ruby
Raw Normal View History

class CoAuthor
include Mongoid::Document
LANGUAGE_TYPES = [ "English", "Chinese" ]
field :name_id, type: BSON::ObjectId
field :co_author, localize: true
field :email
field :type
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
validates :co_author, presence: true
before_save { |coauthor| coauthor.email = email.downcase }
end