开发者

Using increment(attribute) to set value for user's rating

开发者 https://www.devze.com 2022-12-18 08:15 出处:网络
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 so

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

精彩评论

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