Created
November 5, 2012 07:45
-
-
Save inossidabile/4015836 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Should we create a new file called ResourceDSL for this?
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
Hi, thanks for the tip. Watch out, though : master (1.0.x.pre) branch now uses
params["q"]["#{field}_lteq"]
(notice the ending 'q').