Rails 4: Creating Point Rules Using a Gemstone

I am in the process of converting the voting system and reputation of applications from activerecord-reputation-system to merit , because the latter seems to have a much more active core team.

I am trying to establish rules for voting on questions and answers in my application. Ideally, when a user votes for a question, the rule will highlight points for the question itself, as well as the creator of the question.

From the readit section in the point rule section , I see this example:

score 15, on: 'reviews#create', to: [:reviewer, :reviewed]

I understand that :reviewer, and reviewedin this example - those who receive their allocated points. However, when I try to do this in my own point_rules.rb:

score 10, :on => 'questions#vote', :to => :question 

I get the following error:

[merit] NoMethodError on `Question#question` (called from Merit::TargetFinder#other_target)

I know something is missing here, but can someone tell me what it is?

+4
source share
2 answers

Merit works as follows:

If you define a rule without specifying to whom, the default value is current_user

score 15, on: 'reviews#create' # This is for current_user

If you want to assign points to a user outside of current_user, specify it

score 10, :on => 'questions#vote', to: :user

The above example :userrefers to a method question.userthat is the author of a question other than current_user who voted for it.

In the case of OP, the actual reputation and merit of ActiveRecord is for different purposes and cannot be completely changed.

  • ARP , . Meirt .

  • Merit . ARP .

  • Merit , , CanCan. ARP .

  • ARP. Merit , .

+3

, .

score 10, :on => 'questions#vote'

score 10, :on => 'questions#vote', to: :user

, , . , 10 , 10 .

, .

+3

All Articles