简体   繁体   中英

Set the default value for date_range in rails 4

如何在Rails 4中设置默认值?

filter :by_resolved_at_in, as: :date_range,label: "Filtro Resolvido em", :value => Time.now.strftime('%Y-%m-%d')

This is ActiveAdmin , right?

You can't do this in the filter line but you can define a before_filter where the ransack values are initialized.

  before_filter :only => [:index] do
    if params['commit'].blank?
       params['q'] = {by_resolved_at_in: Date.today..Date.today} 
    end
  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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM