ruby-on-railsruby-on-rails-3ruby-on-rails-4voting-system

Using Karma in the thumbs_up gem


I used the thumbs_up gem to create a voting system for my Rails application (which is a Question/Answers application like Stack Overflow).

The problem is that I want the karma of the user (who submits answers and questions) to be based on both answers and questions that he has written.

has_karma :questions, :as => :submitter, :weight => [ 1, 0.5 ]

The above line, wirtten in the user model calculates his karma based on his submitted questions. Would like to make the karma calculated based on both answers and questions.

Is that doable?


Solution

  • I discovered that we can do this :

    has_karma :questions, :as => :user, :weight => [ 1, 1]
     has_karma :answers, :as => :user, :weight => [ 1, 1]
    

    The karma will then be calculated based on both questions and answers. That's great :)