]> git.openstreetmap.org Git - rails.git/blob - app/models/diary_comment.rb
Convert OpenID authentication to generic third party authentication
[rails.git] / app / models / diary_comment.rb
1 class DiaryComment < ActiveRecord::Base
2   belongs_to :user
3   belongs_to :diary_entry
4
5   validates_presence_of :body
6   validates_associated :diary_entry
7
8   after_save :spam_check
9
10   def body
11     RichText.new(read_attribute(:body_format), read_attribute(:body))
12   end
13
14   def digest
15     md5 = Digest::MD5.new
16     md5 << diary_entry_id.to_s
17     md5 << user_id.to_s
18     md5 << created_at.xmlschema
19     md5 << body
20     md5.hexdigest
21   end
22
23   private
24
25   def spam_check
26     user.spam_check
27   end
28 end