# Designing a "community rating" system

**URL:** <https://www.ruby-forum.com/t/designing-a-community-rating-system/178770>\
**Category:** Rails\
**Created:** [November 11, 2009, 2:16am UTC](https://www.ruby-forum.com/t/designing-a-community-rating-system/178770 "2009-11-11T02:16:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [November 11, 2009, 2:16am UTC](https://www.ruby-forum.com/t/designing-a-community-rating-system/178770/1 "2009-11-11T02:16:08Z")

</div>

I need to build a rating system for a project.

The idea is that a number of different user actions within the system  
will contribute to an individual’s standing. Creating one kind of  
thing, reviewing something that someone else has done, participating  
in an activity…basically there are a set of disparate actions that  
will all add up to rank a user.

I’m thinking that I’d like to accumulate these actions in a table so  
that if I need to tweak the ranking algorithm I can do that based on  
the existing data.

My question is, what is the best way to mesh this into my application?

Certainly I could add logic in each controller action as appropriate,  
but that is messy. I’d like something that has some separation from  
the main structure of the app.

Joe

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [November 11, 2009, 3:32pm UTC](https://www.ruby-forum.com/t/designing-a-community-rating-system/178770/2 "2009-11-11T15:32:14Z")

</div>

Joe wrote:

> I need to build a rating system for a project.

[…]

I think there are plugins to do this; have you looked at them?

> Joe

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [November 11, 2009, 7:42pm UTC](https://www.ruby-forum.com/t/designing-a-community-rating-system/178770/3 "2009-11-11T19:42:14Z")

</div>

Joe wrote:

> I haven’t seen any plugins that do this sort of thing.

acts\_as\_rated?

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [November 11, 2009, 8:55pm UTC](https://www.ruby-forum.com/t/designing-a-community-rating-system/178770/4 "2009-11-11T20:55:20Z")

</div>

That is something different, for a given type of model users can rate  
it. So for a blog system other users could rate each post.

I need something more advanced, ratings (community standing, more  
accurately) are driven by how a user behaves in the system.

For example on Yahoo! Answers you get points for signing up, for  
answering questions, having your answer selected as the best answer,  
etc.

Joe

On Nov 11, 10:42 am, Marnen Laibow-Koser \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [November 11, 2009, 3:55pm UTC](https://www.ruby-forum.com/t/designing-a-community-rating-system/178770/5 "2009-11-11T15:55:01Z")

</div>

I haven’t seen any plugins that do this sort of thing. I’m aware of  
things like communityengine and insooshi (railsspace) that provide a  
larger social networking site, but I need something that I can add to  
an existing application.

Something “AOP-like” maybe?

In a Java app I worked on we used JMS for communication across the  
tiers and it was convenient to then just persist the appropriate  
messages for this sort of thing.

On Nov 11, 6:32 am, Marnen Laibow-Koser \<rails-mailing-l…@andreas-  
[s.net](http://s.net)\> wrote:

> Joe wrote:
> 
> > I need to build a rating system for a project.

---

<div class="post-metadata">

**Author:** ![joe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9e5f3/32.png) [@joe](https://www.ruby-forum.com/u/joe)\
**Post date:** [November 12, 2009, 12:30pm UTC](https://www.ruby-forum.com/t/designing-a-community-rating-system/178770/6 "2009-11-12T12:30:04Z")

</div>

Just riffing here…

I would do this as observers on the models that when created increase  
my rating. In that I would save some form of rating event model that  
encapsulates the events. Having the models around would allow you to  
rerate everyone if you found that your weighting of events needs to be  
adjusted.

Something along the lines of: [gist:232816 · GitHub](http://gist.github.com/232816)

I would work it out first with an observer or two and then refactor  
down to a root observer that can be parameterized to do the right  
thing.

Mark
