0
votes

I have an ActiveAdmin class which has a date_range filter as

filter :creation_time

having a start date and end date calender input. I want to add default range i.e. from today's date to tomorrow's date when the dashboard is loaded for the first time. So I tried to do like this :

before_filter only: [:index] do
  params[:q] = {creation_time: Date.today..Date.tomorrow} if params[:commit].blank?
end

But this is not working. How to add default date range here?

1
it didn't work because it is wrong place to patch the filters or it didn't produce correct query? - NeverBe
@NeverBe It is producing the wrong query . It is not taking filter under consideration. without filter it is producing query - abhishek

1 Answers

1
votes

So, I figured it out myself. It can be done as :

before_filter only: [:index] do
  params[:q] = {creation_time_gteq: Date.today, creation_time_lteq: Date.tomorrow} if params[:commit].blank?
end