Sha256: 195aa54c44f3b237db6e99b521688ac8cd69f87bd99550575858a50d8ba33656
Contents?: true
Size: 748 Bytes
Versions: 15
Compression:
Stored size: 748 Bytes
Contents
class TopicPostVote < ActiveRecord::Base belongs_to :user belongs_to :topic_post after_create :create_scores after_update :update_scores def create_scores self.topic_post.created_by_user.forum_points += self.score self.topic_post.created_by_user.forum_votes += 1 self.topic_post.created_by_user.save self.topic_post.score += self.score self.topic_post.save end def update_scores return unless self.score_changed? self.topic_post.created_by_user.forum_points -= self.score_was self.topic_post.created_by_user.forum_points += self.score self.topic_post.created_by_user.save self.topic_post.score -= self.score_was self.topic_post.score += self.score self.topic_post.save end end
Version data entries
15 entries across 15 versions & 1 rubygems