socialforge/app/models/org_document_comment.rb

17 lines
769 B
Ruby
Raw Normal View History

2015-11-12 09:32:00 +08:00
class OrgDocumentComment < ActiveRecord::Base
attr_accessible :content, :creator_id, :organization_id, :parent_id, :reply_id, :title,:sticky,:locked
include Redmine::SafeAttributes
belongs_to :organization
belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id'
acts_as_tree :order => "#{OrgDocumentComment.table_name}.sticky asc, #{OrgDocumentComment.table_name}.created_at desc"
has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy
after_create :document_save_as_org_activity
def document_save_as_org_activity
if(self.parent().nil?)
self.org_acts << OrgActivity.new(:user_id => User.current.id, :container_id => self.organization.id, :container_type => 'Organization')
end
end
end