10

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.

Eric
  • 5,815
  • 3
  • 25
  • 34

1 Answers1

5

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
pixelearth
  • 13,674
  • 10
  • 62
  • 110
  • 2
    active admin filters expects to pass options to ransack seems to me than in this context you may have to override the ransack search logick to force the use of pg scope ... if you have any idea how to do that – nicolas Jun 10 '16 at 12:09