just a simple question which I am unable to figure out. I want to apply multiple filters in rails JsonApiResources
. Here's the resources code I've.
filters :start_date, :end_date, apply: -> (records, value, _options){
byebug
time = ' 00:00:00'
_options[:context][:current_company].documents.where('updated_at > ? AND updated_at < ?',value[0]+time,value[1]+time)
}
This is the url I am calling.
http://localhost:3000/api/v1/dashboard?utf8=%E2%9C%93&filters%5Bstart_date%5D=2017-01-01&filters%5Bend_date%5D=2017-01-01&%5Bwith_tax%5D=0&commit=Search
But it doesn't call this code, instead self.records
is called. But If I change the code to support only one parameter, let's say :start_date
and change filters
to filter
in the above code and the url, than it will work fine.