summaryrefslogtreecommitdiff
path: root/app/models/concerns/spammable.rb
blob: 3b8e6df2da9e992583d995ad0228b9e7b8d034de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module Spammable
  extend ActiveSupport::Concern

  included do
    attr_accessor :spam
    after_validation :check_for_spam, on: :create
  end

  def spam?
    @spam
  end

  def check_for_spam
    self.errors.add(:base, "Your #{self.class.name.underscore} has been recognized as spam and has been discarded.") if spam?
  end
end