Sha256: bece890afb17eb4ea22eac9138c307744e5fc539c1601821eb2ee0f8a8fab6ff

Contents?: true

Size: 724 Bytes

Versions: 10

Compression:

Stored size: 724 Bytes

Contents

# == Schema Information
#
# Table name: proclaim_comments
#
#  id         :integer          not null, primary key
#  post_id    :integer
#  parent_id  :integer
#  author     :string
#  body       :text
#  created_at :datetime         not null
#  updated_at :datetime         not null
#

module Proclaim
	class Comment < ActiveRecord::Base
		acts_as_tree order: 'created_at ASC', dependent: :destroy
		belongs_to :post, inverse_of: :comments
		after_initialize :maintainPost
		after_create :notifyPostSubscribers

		validates_presence_of :body, :author, :post

		private

		def maintainPost
			if parent
				self.post = parent.post
			end
		end

		def notifyPostSubscribers
			post.notifyPostSubscribers(self)
		end
	end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
proclaim-0.3.1 app/models/proclaim/comment.rb
proclaim-0.3.0 app/models/proclaim/comment.rb
proclaim-0.2.4 app/models/proclaim/comment.rb
proclaim-0.2.2 app/models/proclaim/comment.rb
proclaim-0.2.1 app/models/proclaim/comment.rb
proclaim-0.2.0 app/models/proclaim/comment.rb
proclaim-0.1.3 app/models/proclaim/comment.rb
proclaim-0.1.2 app/models/proclaim/comment.rb
proclaim-0.1.1 app/models/proclaim/comment.rb
proclaim-0.1.0 app/models/proclaim/comment.rb