Active Record Reputation System

码农软件 · 软件分类 · 其他开发相关 · 2019-10-24 19:41:33

软件介绍

这是 Twitter 公司基于 Rails ActiveRecord 的声望系统

Alt text

安装方法:

gem install reputation_system && rails generator reputation_system && rake db:migrate

使用方法:

class User < ActiveRecord::Base
  has_many :answers
  has_many :questions

  has_reputation :karma,
      :source => [
          { :reputation => :questioning_skill, :weight => 0.8 },
          { :reputation => :answering_skill }],
      aggregated_by => :sum

  has_reputation :questioning_skill,
      :source => { :reputation => :votes, :of => :questions },
      :aggregated_by => :sum

  has_reputation :answering_skill,
      :source => { :reputation => :avg_rating, :of => :answers },
      :aggregated_by => :sum
end

class Answer < ActiveRecord::Base
  belongs_to :user, :as => :author

  has_reputation :avg_rating,
      :source => :user,
      :aggregated_by => :average,
      :source_of => [{ :reputation => :answering_skill, :of => :author }]
end


class Question < ActiveRecord::Base
  belongs_to :user

  has_reputation :votes,
      :source => :user,
      :aggregated_by => :sum
end

@answer.add_evaluation(:avg_rating, 3, @user)
@question.add_evaluation(:votes, 1, @user)

更多介绍请看软件首页

本文地址:https://codercto.com/soft/d/17483.html

怎样解题

怎样解题

[美] G. 波利亚 / 涂泓、冯承天 / 上海科技教育出版社 / 2007-5 / 16.00元

怎样解题:数学思维的新方法,ISBN:9787542843876,作者:(美)波利亚 著;徐泓、冯承天 译一起来看看 《怎样解题》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具