Skip to content

Instantly share code, notes, and snippets.

@koheisg
Created May 30, 2021 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koheisg/df64b6f7fbded2d1bbbe35e5c591599a to your computer and use it in GitHub Desktop.
Save koheisg/df64b6f7fbded2d1bbbe35e5c591599a to your computer and use it in GitHub Desktop.
Select less than the day after the input date by ransack to avoid not include the value of input date.
.field
= f.label :created_at
= f.date_field :created_at_gteq, class: 'datepicker'
= f.date_field :created_at_lt_next_day, class: 'datepicker'
Ransack.configure do |config|
config.add_predicate 'lt_next_day',
arel_predicate: 'lt',
formatter: proc {|v| v.tomorrow.beginning_of_day},
compounds: false
end
Model Load (1.8ms) SELECT `models`.* FROM `models` WHERE (`models`.`created_at` < '2021-06-01 00:00:00') LIMIT 100 OFFSET 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment