public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
insoshi / app / models / forum_post.rb
100644 39 lines (31 sloc) 1.102 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# == Schema Information
# Schema version: 28
#
# Table name: posts
#
# id :integer(11) not null, primary key
# blog_id :integer(11)
# topic_id :integer(11)
# person_id :integer(11)
# title :string(255)
# body :text
# blog_post_comments_count :integer(11) default(0), not null
# type :string(255)
# created_at :datetime
# updated_at :datetime
#
 
class ForumPost < Post
  is_indexed :fields => [ 'body' ],
             :conditions => "type = 'ForumPost'",
             :include => [{:association_name => 'topic', :field => 'name'}]
 
  attr_accessible :body
  
  belongs_to :topic, :counter_cache => true
  belongs_to :person, :counter_cache => true
  
  validates_presence_of :body, :person
  validates_length_of :body, :maximum => 5000
  
  after_create :log_activity
    
  private
  
    def log_activity
      add_activities(:item => self, :person => person)
    end
end