summaryrefslogtreecommitdiff
path: root/app/models/concerns/updated_at_filterable.rb
blob: edb423b7828cd594da103ae4c0515965cf4545da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
module UpdatedAtFilterable
  extend ActiveSupport::Concern

  included do
    scope :updated_before, ->(date) { where(scoped_table[:updated_at].lteq(date)) }
    scope :updated_after, ->(date) { where(scoped_table[:updated_at].gteq(date)) }

    def self.scoped_table
      arel_table.alias(table_name)
    end
  end
end