Rails3, kaminari and pg_search, Maintaining a search subset of data when sorting?

I hope someone may have solved this issue before. It involves rails3,
kaminari and pg_search.

I’ve got pg_search working, but now the search is returned and the
default order is not maintained. I don’t mind having the subset
returned in any order. But I want to maintain the subset of records
returned by the search query and still be able to click on the column
headers to sort the new data subset.

Now, when I select any of the column headers after a search, I get all
of the db records displayed. If I change the search box to contain no
text, I’d like all records should be displayed.

Is there a sequence of method calls that I can setup so that the
subset of data is maintained while the column headers are still
sortable?

I am now using this call sequence in my controller:

from: /tips/app/controllers/tips_controller.rb

def index
@tips = Tip.text_search(params[:query]).order(sort_column + ’ ’ +
sort_direction).page(params[:page])
end

Can anyone suggest a better approach?

Thanks,

Capt. Downer