public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
mephisto / app / models / event.rb
100644 20 lines (15 sloc) 0.66 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Event < ActiveRecord::Base
  validates_presence_of :article_id, :site_id
  validate :content_and_user_added
 
  # article being updated
  belongs_to :article, :foreign_key => 'article_id'
 
  # updater of the article at the time of the event
  belongs_to :user, :with_deleted => true
  
  belongs_to :comment
  belongs_to :site
 
  protected
    def content_and_user_added
      errors.add_to_base "Title or Body must be changed" unless %w(publish comment).include?(mode) || article.changed?(:title) || article.changed?(:body)
      errors.add_to_base "User must be provided for Article events" unless (mode == 'comment' && author) || user_id
    end
end