Skip to content

Commit

Permalink
Added support for numeric fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Ostrzy committed Jul 27, 2012
1 parent e93155c commit da56475
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/active_admin/mongoid/adaptor.rb
Expand Up @@ -27,7 +27,8 @@ def method_missing(method_id, *args, &block)


def is_query(method_id) def is_query(method_id)
method_id.to_s =~ /_contains$/ || method_id.to_s =~ /_contains$/ ||
method_id.to_s =~ /_eq$/ method_id.to_s =~ /_eq$/ ||
method_id.to_s =~ /_(gt|lt)/
end end


def get_query_hash(search_params) def get_query_hash(search_params)
Expand All @@ -42,6 +43,10 @@ def mongoidify_search(k, v)
[get_attribute(k, '_contains'), Regexp.new(Regexp.escape("#{v}"), Regexp::IGNORECASE)] [get_attribute(k, '_contains'), Regexp.new(Regexp.escape("#{v}"), Regexp::IGNORECASE)]
elsif k =~ /_eq$/ elsif k =~ /_eq$/
[get_attribute(k, '_eq'), v] [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 else
[k, v] [k, v]
end end
Expand Down

0 comments on commit da56475

Please sign in to comment.