add co-author db and curd page, but it can't destory it...

This commit is contained in:
Rueshyna committed 2012-11-21 01:56:30 +08:00
1 parent ccfecb8243
commit 95fc5676bf
7 files changed
+160

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
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