Search code examples
ruby-on-railsfull-text-searchthinking-sphinx

Ruby on Rails thinking-sphinx has many through indexing


Cheers! I have tour model with these associations:

  has_many :tour_in_the_countries
  has_many :country, :through => :tour_in_the_countries

And in tour_index.rb

ThinkingSphinx::Index.define :tour, :with => :active_record do
  indexes :title
  indexes :preview
end

How to add to index country's name in this case?


Solution

  • This should do the trick:

    indexes tour_in_the_countries.country.name, :as => :countries