Permalink
Browse files

Fix for ordering with a default_scope order in place.

  • Loading branch information...
joost committed Aug 22, 2012
1 parent dcf4d82 commit 85e931c984b345805122516f3fb367e337f1bd7b
@@ -18,7 +18,9 @@ def destroy_all
# Use meta_search and kaminari gem to load collection.
# Saves the per parameter to the user's session[:admin_per].
def collection
- @search ||= end_of_association_chain.ransack(params[:q])
+ @search ||= end_of_association_chain
+ @search = @search.reorder('') if params[:q].present? && params[:q][:s].present? # We reorder to nothing if we have Ransack sort parameters.
+ @search = @search.ransack(params[:q])
get_collection_ivar || begin
session[:admin_per] = params[:per] || session[:admin_per] # Save the per_page to the user's session
c = @search.result.page(params[:page]).per(session[:admin_per])

0 comments on commit 85e931c

Please sign in to comment.