Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can thinking-sphinx ransack work together?

Our project is using Ransack at the moment, we are thinking to introduce Thinking-Sphinx. However they both use search keyword. Is any way to use Thinking-Sphinx and Ransack in a same project?

Thank in advance.

like image 498
Ben Zhang Avatar asked Apr 12 '12 02:04

Ben Zhang


1 Answers

Ransack's search method is just an alias. You can use the ransack method instead.

Instead of:

@q = Person.search(params[:q])
@people = @q.result(:distinct => true)

Use:

@q = Person.ransack(params[:q])
@people = @q.result(:distinct => true)

Person.search should call ThinkingSphinx as usual.

like image 156
Evan Muehlhausen Avatar answered Nov 13 '22 00:11

Evan Muehlhausen