Extracts Flammable module from comment & debate

This commit is contained in:
kikito
2015-09-12 14:03:38 +02:00
parent 800fa7c47f
commit d57d538f3b
3 changed files with 21 additions and 25 deletions

19
lib/flaggable.rb Normal file
View File

@@ -0,0 +1,19 @@
module Flaggable
extend ActiveSupport::Concern
included do
has_many :flags, as: :flaggable
scope :flagged, -> { where("flags_count > 0") }
scope :pending_flag_review, -> { where(ignored_flag_at: nil, hidden_at: nil) }
scope :with_ignored_flag, -> { where.not(ignored_flag_at: nil).where(hidden_at: nil) }
end
def ignored_flag?
ignored_flag_at.present?
end
def ignore_flag
update(ignored_flag_at: Time.now)
end
end