0
目標是當他的評論得到upvote時給用戶點。現在只有在創建評論(5分)時纔給出分數,並且不計數upvotes。寶石'優點'不包括點
我查看了this answer,根據它我的代碼是正確的。我正在使用acts_as_votable寶石獲得upvotes/downvotes。
的Gemfile
gem 'merit', '~> 2.1.1'
comments_controller
def upvote
@comment.liked_by current_user
render "update_likes"
end
point_rules
module Merit
class PointRules
include Merit::PointRulesMethods
def initialize
score 5, :on => ['comments#create'], :to => [:user], category: 'gold_points'
score 2, :on => ['comments#upvote'], :to => [:user], category: 'gold_points'
end
end
end
用戶模型
class User < ActiveRecord::Base
has_merit
顯示點
<%= @user.points(category: 'gold_points') %>