Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can ransack use pg_search?

I'd like to use ransack (via ActiveAdmin) to do full-text searches on a model.

How can I get ransack to use pg_search for its query? I want to run queries that, among other query components, use pg_search functionality.

like image 986
Eric Avatar asked Aug 03 '15 16:08

Eric


1 Answers

You don't need ransack to use pg_search, just combine the scopes. They're meant to work together.

Here I'm using several different gems to work together for a search:

@lessons = Lesson.
             by_fuzzy_name("foo"). # pg_search scope
             by_instructor_fullname("bob"). # pg_search scope
             ransack(ransack_search_options).result. #ransack scope
             active. # rails scope
             page(page) # kaminari pagination
like image 158
pixelearth Avatar answered Oct 17 '22 12:10

pixelearth