Class: TopicPostVote
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- TopicPostVote
- Defined in:
- app/models/topic_post_vote.rb
Instance Method Summary collapse
Instance Method Details
#create_scores ⇒ Object
9 10 11 12 13 14 15 |
# File 'app/models/topic_post_vote.rb', line 9 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 |
#update_scores ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/topic_post_vote.rb', line 17 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 |