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

  included do
    scope :created_before, ->(date) { where(scoped_table[:created_at].lteq(date)) }
    scope :created_after, ->(date) { where(scoped_table[:created_at].gteq(date)) }

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