开发者

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜