I have a fabrics model that belongs to multiple other tables.
class Fabric < ActiveRecord::Base
validates :name, presence: true
belongs_to :design
belongs_to :composition
belongs_to :collection
belongs_to :style
belongs_to :origin
belongs_to :texture
belongs_to :supplier
has_and_belongs_to_many :colours
searchable do
text :name, :boost => 5
text :description
text :composition do
composition.name
end
text :collection do
collection.name
end
text :style do
style.name
end
text :origin do
origin.name
end
text :texture do
texture.name
end
text :supplier do
supplier.name
end
end
end
I have setup all of the reverse associations (Has_many) etc.
However I do not seem to be able to get the fulltext search to query the name fields of all of these associated tables.
Any help would be greatly appreciated.
@search = Fabric.search do
fulltext params[:search]
end
@fabrics = @search.results
Ross
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…