]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/diary_comment.rb
Rework coordinates to avoid scientific formatting of small numbers. Fixes #1509
[rails.git] / app / models / diary_comment.rb
index b915e027a9e1f49d62b2443b4f7b2b46f3630224..2796eb612ac8eea869270fc7cee2f72bb73b6da8 100644 (file)
@@ -2,10 +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
 
-  attr_accessible :body
+  after_save :spam_check
+
+  def body
+    RichText.new(self[:body_format], self[:body])
+  end
 
   def digest
     md5 = Digest::MD5.new
@@ -15,4 +19,10 @@ class DiaryComment < ActiveRecord::Base
     md5 << body
     md5.hexdigest
   end
+
+  private
+
+  def spam_check
+    user.spam_check
+  end
 end