X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/0d3a9ed9cb47ce3b89ea9eaffbb589f9a9ff6d22..f6c7ed601159aca360da09948f1544172ddf1a41:/app/models/diary_entry.rb?ds=sidebyside diff --git a/app/models/diary_entry.rb b/app/models/diary_entry.rb index 64a412d28..de2a42ae3 100644 --- a/app/models/diary_entry.rb +++ b/app/models/diary_entry.rb @@ -1,7 +1,7 @@ class DiaryEntry < ActiveRecord::Base - belongs_to :user + belongs_to :user, :counter_cache => true belongs_to :language, :foreign_key => 'language_code' - + has_many :comments, :class_name => "DiaryComment", :include => :user, :order => "diary_comments.id" @@ -27,6 +27,7 @@ class DiaryEntry < ActiveRecord::Base attr_accessible :title, :body, :language_code, :latitude, :longitude after_initialize :set_defaults + after_save :spam_check def body RichText.new(read_attribute(:body_format), read_attribute(:body)) @@ -37,4 +38,8 @@ private def set_defaults self.body_format = "markdown" unless self.attribute_present?(:body_format) end + + def spam_check + user.spam_check + end end