0

The goal is to give a user points when his comment gets an upvote. Now it just gives points when the comment is created(5 points) and doesn't count upvotes.

I've looked at this answer and according to it my code is correct. I'm using acts_as_votable gem for 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

user model

class User < ActiveRecord::Base
  has_merit

display points

<%= @user.points(category: 'gold_points') %>
Community
  • 1
  • 1
Absurdim
  • 233
  • 3
  • 15

1 Answers1

0

I found the answer:

change

render "update_likes"

to

render :nothing => true
Absurdim
  • 233
  • 3
  • 15