Permalink
Browse files

Added support for numeric fields

  • Loading branch information...
1 parent e93155c commit da56475bd8ee7d17a16b6583dcb723cc7e46ef71 @Ostrzy committed Jul 27, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 lib/active_admin/mongoid/adaptor.rb
View
7 lib/active_admin/mongoid/adaptor.rb
@@ -27,7 +27,8 @@ def method_missing(method_id, *args, &block)
def is_query(method_id)
method_id.to_s =~ /_contains$/ ||
- method_id.to_s =~ /_eq$/
+ method_id.to_s =~ /_eq$/ ||
+ method_id.to_s =~ /_(gt|lt)/
end
def get_query_hash(search_params)
@@ -42,6 +43,10 @@ def mongoidify_search(k, v)
[get_attribute(k, '_contains'), Regexp.new(Regexp.escape("#{v}"), Regexp::IGNORECASE)]
elsif k =~ /_eq$/
[get_attribute(k, '_eq'), v]
+ elsif k =~ /_gt$/
+ [get_attribute(k, "_gt").to_sym.gt, v]
+ elsif k =~ /_lt$/
+ [get_attribute(k, "_lt").to_sym.lt, v]
else
[k, v]
end

0 comments on commit da56475

Please sign in to comment.