The :to
parameter can be a method name, which called over the target object (in this case, @registration
) should retrieve the object to badge. If using it this way, when you put :user
, then merit is internally running @registration.user
to find who to badge, which is not what we want.
:to
can also be :itself
, in that case it badges the target object (@registration in your case, which, if a User, should work for you).
I believe you want to badge whoever is current_user
, which is this option's default (:action_user
), so you shouldn't need to define :to
option.
That said, for merit to badge, condition has to be true
, and it can happen that there's no user
to pass as a parameter to that rule. Try it without the parameter:
grant_on 'registrations#create', badge: 'Pioneer' do
User.count < 101
end