I would like to use the Merit Gem to create a badges and points system on my website. However, I would like it for some badges to reset after each month. For example, a monthly badge of 20 comments. This would require users to be consistent on the site. Is it possible to do this with Merit? I know that there is a "temporary" feature, that resets the badge based on if the conditions are no longer met, but I would like a time-based way to reset the badges.
Thank you!
Sure:
grant_on 'comments#create', badge: 'frequent-commenter', to: :user, temporary: true do |comment|
comment.user.comments.where(:created_at.gte => (Date.today - 30)).count >= 20
end
With this code the badge will be revoked if the condition no longer holds