搜索has_many:通过在rails中的太阳黑子中的关联

时间:2015-10-06 10:15:52

标签: ruby-on-rails ruby-on-rails-3 activerecord sunspot sunspot-rails

我有一个型号产品

class Product < ActiveRecord::Base

belongs_to :user
has_many :category_products
has_many :categories , through: :category_products

我想在类别和用户中进行全文搜索,但它无法正常工作

searchable do
text :title, :boost => 5
text :description
text :categories do 
  categories.map(&:name)
end
text :user do
  user.first_name
end

0 个答案:

没有答案