Adds User.comment_flags

This commit is contained in:
kikito
2015-09-01 13:09:35 +02:00
parent c2faf0ef92
commit d0c7c7fe79
3 changed files with 29 additions and 0 deletions

View File

@@ -9,6 +9,8 @@ class Flag < ActiveRecord::Base
flaggable_id: flaggable.id)
end)
scope :for_comments, ->(comments) { where(flaggable_type: 'Comment', flaggable_id: comments) }
def self.flag(user, flaggable)
return false if flagged?(user, flaggable)
create(user: user, flaggable: flaggable)