Skip to content

Instantly share code, notes, and snippets.

@inossidabile
Created November 5, 2012 07:45
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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
@michaelbaudino
Copy link

Hi, thanks for the tip. Watch out, though : master (1.0.x.pre) branch now uses params["q"]["#{field}_lteq"] (notice the ending 'q').

@NayanaBhagat
Copy link

Should we create a new file called ResourceDSL for this?

@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