keep track of post approvals to prevent approval cycles

This commit is contained in:
Albert Yi
2016-10-31 17:51:44 -07:00
parent 03fd48c989
commit 2dbb869188
7 changed files with 159 additions and 4 deletions

View File

@@ -0,0 +1,12 @@
class PostApproval < ActiveRecord::Base
belongs_to :user
belongs_to :post
def self.prune!
where("created_at < ?", 1.month.ago).delete_all
end
def self.approved?(user_id, post_id)
where(user_id: user_id, post_id: post_id).exists?
end
end