2012-11-30 1 views
2

solr을 사용하여 제품을 검색하려고하는데 잘 작동합니다. 내가 공급자 모델은 0 또는Ruby on Rails Sunspot solr 상태가 포함 된 연결

내 모델 1 인에서 상태 필드를 사용하여, has_and_belongs_to_many하여 제품과 관련된 공급 업체를 제한하려는 것을 제외하고 있습니다

"Product.rb"

has_and_belongs_to_many :suppliers, :class_name => 'Company' 

searchable do 
    text :name 
    text :brand 
    text :description 
end 

"Company.rb"를 검색하십시오

attr_accessible :status 

has_and_belongs_to_many :products 

내가 사용하고 있습니다 :

@search = Product.search(:include => :suppliers) do 
    fulltext params[:s] 
    with :status, 1 # This gives error as status is not a field in Product 
end 

상태 1 인 공급 업체 만 어떻게 포함시킬 수 있습니까?

답변

0

당신은 검색

searchable do 
    text :name 
    text :brand 
    text :description 
    boolean :status 
end 
의 상태를 놓치고