X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/23b8672bc9a8449f6a89d94b25ea036f4815e4bc..7a4e13ecad1017a526950c60bfe674d4277632e7:/app/models/diary_comment.rb diff --git a/app/models/diary_comment.rb b/app/models/diary_comment.rb index 0013606d0..2796eb612 100644 --- a/app/models/diary_comment.rb +++ b/app/models/diary_comment.rb @@ -2,8 +2,14 @@ class DiaryComment < ActiveRecord::Base belongs_to :user belongs_to :diary_entry - validates_presence_of :body - validates_associated :diary_entry + validates :body, :presence => true + validates :diary_entry, :user, :associated => true + + after_save :spam_check + + def body + RichText.new(self[:body_format], self[:body]) + end def digest md5 = Digest::MD5.new @@ -13,4 +19,10 @@ class DiaryComment < ActiveRecord::Base md5 << body md5.hexdigest end + + private + + def spam_check + user.spam_check + end end