|
|
|
@ -3,9 +3,9 @@ class Memo < ActiveRecord::Base
|
|
|
|
|
belongs_to :forum
|
|
|
|
|
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
|
|
|
|
|
|
|
|
|
|
validates_presence_of :author_id, :forum_id, :subject
|
|
|
|
|
validates_presence_of :author_id, :forum_id, :subject,:content
|
|
|
|
|
# 若是主题帖,则内容可以是空
|
|
|
|
|
validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? }
|
|
|
|
|
#validates :content, presence: true, if: Proc.new{|o| !o.parent_id.nil? }
|
|
|
|
|
validates_length_of :subject, maximum: 50
|
|
|
|
|
validates_length_of :content, maximum: 3072
|
|
|
|
|
validate :cannot_reply_to_locked_topic, :on => :create
|
|
|
|
|