How can ransack use pg_search?
Asked Answered
A

1

11

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.

Agger answered 3/8, 2015 at 16:20 Comment(4)
did you find a solution, i'm having the same problem . Activeadmin is mapped to ransack can't make it use the fulltext pg scopeQualls
I got off of activeadmin in favor of administrate. There you can do anything you want without as much of an uphill climb.Agger
ahaha i've dive too much into it to quit now. Thx for the reply anywayQualls
does anybody have a solution ?Qualls
K
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
Kittiekittiwake answered 6/2, 2016 at 1:48 Comment(1)
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 thatQualls

© 2022 - 2024 — McMap. All rights reserved.