From fb2d683ab0a735e778b226bf74554d15d636e0fd Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Sat, 30 Jan 2016 12:42:21 +0100 Subject: [PATCH] Auto accept badge if votes > 2 --- models/vote.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/models/vote.rb b/models/vote.rb index e6de9a7..04a9820 100644 --- a/models/vote.rb +++ b/models/vote.rb @@ -1,4 +1,10 @@ class Vote < ActiveRecord::Base belongs_to :user belongs_to :badge_change + + after_create do + if self.badge_change.votes.count > 2 + badge_change.accept! + end + end end