我正在使用 Rails 3.2 和 Thinking Sphinx 3。我有以下相关模型:
# country.rb
class Country < ActiveRecord::Base
has_many :states
end
# state.rb
class State < ActiveRecord::Base
belongs_to :country
has_many :state_shops
has_many :shops, :through => :state_shops
end
# state_shop.rb
class StateShop < ActiveRecord::Base
belongs_to :state
belongs_to :shop
end
# shop.rb
class Shop < ActiveRecord::Base
end
在country.rb
中,我想搜索 的名称shop
。这是我的索引country
:
# country_index.rb
ThinkingSphinx::Index.define :country, :with => :active_record do
indexes :name
has budget, duration, overall_rating, created_at
end
我的关联索引应该如何搜索shop.name
?