Last active
June 27, 2016 14:39
-
-
Save ktec/357c217630b37b057ab252eb3e80783e to your computer and use it in GitHub Desktop.
Revisions
-
ktec revised this gist
Jun 27, 2016 . No changes.There are no files selected for viewing
-
ktec created this gist
Jun 27, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ # frozen_string_literal: true class Things < ApplicationRecord scope :filter_after_date, -> (date) { where(created_at_as_date.gteq(date)) } scope :filter_before_date, -> (date) { where(created_at_as_date.lteq(date)) } def self.created_at_as_date Arel::Nodes::NamedFunction.new "DATE", [ arel_table[:created_at] ] end end