mardi 6 octobre 2015

Search has_many:through association in sunspot in rails

I have a model Product

class Product < ActiveRecord::Base

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

I want a full text search in categories and user also but it can't work

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

end

Aucun commentaire:

Enregistrer un commentaire