]> git.openstreetmap.org Git - rails.git/blob - app/models/diary_comment.rb
Add padding between the last diary post and the pagination links
[rails.git] / app / models / diary_comment.rb
1 class DiaryComment < ActiveRecord::Base
2   belongs_to :user
3   belongs_to :diary_entry
4
5   validates :body, :presence => true
6   validates :diary_entry, :user, :associated => true
7
8   after_save :spam_check
9
10   def body
11     RichText.new(self[:body_format], self[: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