Commit 72da898b by liyijie

add ransack paginate options

parent 1e191000
...@@ -37,6 +37,9 @@ class SimpleController::BaseController < ::InheritedResources::Base ...@@ -37,6 +37,9 @@ class SimpleController::BaseController < ::InheritedResources::Base
def defaults(options) def defaults(options)
view_path = options.delete(:view_path) view_path = options.delete(:view_path)
@ransack_off = options.delete(:ransack_off)
@paginate_off = options.delete(:paginate_off)
set_view_path view_path if view_path.present? set_view_path view_path if view_path.present?
super(options) super(options)
end end
...@@ -65,11 +68,9 @@ class SimpleController::BaseController < ::InheritedResources::Base ...@@ -65,11 +68,9 @@ class SimpleController::BaseController < ::InheritedResources::Base
end end
def ransack_paginate(association) def ransack_paginate(association)
association.ransack( association = association.ransack(params[:q]).result.distinct unless self.class.instance_variable_get(:@ransack_off)
params[:q] association = association.paginate(page: params[:page], per_page: params[:per_page]) unless self.class.instance_variable_get(:@paginate_off)
).result.distinct.paginate( association
page: params[:page], per_page: params[:per_page]
)
end end
def collection def collection
......
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