我有一个属于多个其他表的织物模型。
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
我已经设置了所有反向关联(Has_many)等。但是我似乎无法获得全文搜索来查询所有这些关联表的名称字段。
任何帮助将不胜感激。
@search = Fabric.search do
fulltext params[:search]
end
@fabrics = @search.results
罗斯