title: Add scope in concerns for various models
body: <p>In apps/models/concerns/deactivable.rb</p>
  
  <pre><code>module Deactivatable
    extend ActiveSupport::Concern
  
    included do
      scope :alive, -&gt; { where(:deactivated_at =&gt; nil) }
    end
  
    def deactivate(t = Time.current)
      update_attribute(:deactivated_at,t)
    end
  
    def activate
      update_attribute(:deactivated_at,nil)
    end
  
    def deactivated?
      deactivated_at.present?
    end
  
  end
  </code></pre>
  
  <p>This is being included in 2 models, app/models/activity_rules/activity_detection_rule.rb and app/models/concerns/generic_campaign.rb.</p>
  
  <p>There are 2 more models which contain the same methods with different attribute name.</p>
  
  <p>In redeemable.rb,</p>
  
  <pre><code>class Redeemable &lt; ActiveRecord::Base
    scope :alive, -&gt; { where("(deactivation_date is null) and (expiry_date is null or expiry_date &gt;= ?)",Date.today) }
  
    def deactivate(t = Time.current)
      update_attribute(:deactivation_date,t)
    end
  
    def reactivate
      update_attribute(:deactivation_date,nil)
    end
  
    def deactivated?
      deactivation_date.present?
    end
  end
  </code></pre>
  
  <p>and in surprise_set.rb</p>
  
  <pre><code>scope :alive, -&gt; { where("deactivation_date is null") }
  </code></pre>
  
  <p>with the same 3 methods as redeemable.rb.</p>
  
  <p>How to use Deactivable concern to DRY up the other two models?</p>