Using increment(attribute) to set value for user's rating
I'm thinking abo开发者_如何转开发ut writing an app with question and answer model. Answer has increment attribute that anyone can change to change the rating value. So if I click up on answer that someone else posted, the answer will show 1 point.
But, how do I/can I, use that to increase the rating of the overall user. In essence it is very similar to Stackoverflow. If you rate my answer up, my user rating goes up. I want the same functionality.
Wouldn't it simply be a matter of incrementing the user when you increment the answer?
answer.increment(:votes)
user.increment(:rating)
精彩评论