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 ie 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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.