if coauthor not in coauthor db then it will be add in db

This commit is contained in:
Rueshyna authored and chris committed 2012-12-04 00:31:06 +08:00
1 parent 7f7b33f310
commit eb97d417bd
2 files changed
+20 -2

No files matched your search

+3 -2
View File
@@ -9,11 +9,12 @@ class CoAuthor
field :type
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
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 }
before_save { |coauthor| coauthor.email = email.downcase if not coauthor.email.nil?}
end