Commit c9c54592 by liyijie

feat: 增加q: { refs: 'entry' } 或者 q: { refs: ['entry'] }的查询,解决postgresql distinct order报错的问题

parent f52ef1e1
...@@ -212,6 +212,10 @@ class SimpleController::BaseController < ::InheritedResources::Base ...@@ -212,6 +212,10 @@ class SimpleController::BaseController < ::InheritedResources::Base
association = ransack_association(association, params[:q]) unless self.class.instance_variable_get(:@ransack_off) || params[:q].blank? association = ransack_association(association, params[:q]) unless self.class.instance_variable_get(:@ransack_off) || params[:q].blank?
association = ransack_association(association, params[:sub_q]) unless self.class.instance_variable_get(:@ransack_off) || params[:sub_q].blank? association = ransack_association(association, params[:sub_q]) unless self.class.instance_variable_get(:@ransack_off) || params[:sub_q].blank?
association = association.distinct unless self.class.instance_variable_get(:@distinct_off) || !association.respond_to?(:distinct) || !active_record? association = association.distinct unless self.class.instance_variable_get(:@distinct_off) || !association.respond_to?(:distinct) || !active_record?
if params[:q][:refs].present?
_refs = Array(params[:q][:refs]).map(&:to_sym)
association = association.includes(*_refs).joins(*_refs)
end
association = association.paginate(page: params[:page], per_page: params[:per_page]) unless self.class.instance_variable_get(:@paginate_off) association = association.paginate(page: params[:page], per_page: params[:per_page]) unless self.class.instance_variable_get(:@paginate_off)
association association
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