Commit c3b0c42a by liyijie

feat: 支持mongoid ransack搜索

parent 65e80524
...@@ -328,8 +328,11 @@ class SimpleController::BaseController < ::InheritedResources::Base ...@@ -328,8 +328,11 @@ class SimpleController::BaseController < ::InheritedResources::Base
if active_record? if active_record?
association.ransack(query_params).result association.ransack(query_params).result
else else
selector = RansackMongo::Query.parse(query_params) _params = query_params.clone
association.where(selector) order_params = _params.delete(:s)
selector = RansackMongo::Query.parse(_params)
order_params.present? ?
association.where(selector).order(*Array(order_params)) : association.where(selector)
end end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment