I know its been a long time, but I'm working with the Chewy gem right now, so here it goes:
Assuming you have a TasksIndex
with start_at
and end_at
fields well defined as of date
type and with correct format:
field :start_at, type: 'date', format: 'basic_date_time_no_millis' # example, you can use other formats
field :end_at, type: 'date', format: 'basic_date_time_no_millis'
Then your filter can be like this:
def tasks_including_date(target_date)
formatted_target_date = target_date.strftime('%Y-%m-%d')
TasksIndex.filter{start_at <= formatted_target_date}.filter{end_at >= formatted_target_date}
end
Then you can just:
tasks_including_date(Date.today)
If you want the results itself, instead of the just the filtered scope, just use a to_ary
on the result. It will handle you an aray with the results.