Skip to content

Instantly share code, notes, and snippets.

@inossidabile
Created November 5, 2012 07:45
Show Gist options
  • Save inossidabile/4015836 to your computer and use it in GitHub Desktop.
Save inossidabile/4015836 to your computer and use it in GitHub Desktop.
module ActiveAdmin
class ResourceDSL
def filter(*args)
field = args[0]
klass = @config.resource_class_name.constantize
type = klass.columns.select{|c| c.name == field.to_s}.first.try(:type)
if type == :datetime
controller do
before_filter :only => :index do
if !params["q"].blank? && !params["q"]["#{field}_lte"].blank?
params["q"]["#{field}_lte"] += " 23:59:59.999999"
end
end
end
end
super
end
end
end
@mrjman
Copy link

mrjman commented Aug 22, 2015

The solutions mentioned in activeadmin/activeadmin#3529 by chrp and keithlayne work great and are a little cleaner in my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment