22 lines
627 B
Ruby
22 lines
627 B
Ruby
|
class ConferenceCoAuthor
|
||
|
include Mongoid::Document
|
||
|
|
||
|
LANGUAGE_TYPES = [ "English", "Chinese" ]
|
||
|
|
||
|
field :name_id, type: BSON::ObjectId # this is author
|
||
|
field :co_author, localize: true
|
||
|
field :email
|
||
|
|
||
|
belongs_to :conference_co_author_relations
|
||
|
has_and_belongs_to_many :writing_conferences
|
||
|
|
||
|
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/
|
||
|
validates :email, format: { with: VALID_EMAIL_REGEX },
|
||
|
allow_blank: true,
|
||
|
uniqueness: { case_sensitive: false }
|
||
|
|
||
|
validates :co_author, presence: true
|
||
|
before_save { |coauthor| coauthor.email = email.downcase if not coauthor.email.nil?}
|
||
|
end
|
||
|
|