captdowner
2012-May-09 17:42 UTC
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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.