Tuesday, 27 March 2012

Thinking Sphinx With Rails Engine

Currently i am working with rails 3.2 application,i am using thinking sphinx for full text search.

In this application i have several module that are works independently so it's nice to have build each module separately(Engine). So Engine also has search which is built on sphinx.


Now after integrating this engine with main application when i start indexing it will not index Engine model may be it's path issue or load issue,after googling and traversing source code couple of solution are found.

One of them is create  file under initializers directory of each engine or add code where it is initialized so when rails is load below code is hooked up.

module ThinkingSphinx
  class Context
    def load_models
      Billing::Category
      Billing::Item
    end
  end
end
It will solve my purpose and indexing run perfectly fine.
There are others way also but i find this is easy. Is there any other way kindly share. 

1 comment: