関連するすべてのモデル属性を簡単に検索したい前に質問されましたが、これにはまだ問題があります:
プロファイル モデル
has_one :match
searchable do
integer :id
string :country
string :state
string :city
end
マッチモデル
belongs_to :profile
searchable do
integer :id
string :looking_for_education do
match.looking_for_education
end
integer :age_from
integer :age_to
end
ProfilesController#Index
def index
@search = Sunspot.search Profile do
with(:country, params[:country]) # this is a profile attribute
with(:state, params[:state]) # this is a profile attribute
with(:looking_for_education, "high school") # this should search *inside*
#the match attribute's,
#where **match** belongs_to
#**profile**
end
@profiles = @search.results
end
編集#1
:looking_for_education do ブロックを使用して、最初の回答の提案のように検索可能なブロックを書き直しました。まだ未定義のメソッド「looking_for」で失敗する #
整数:idをインデックスに追加しても同じ問題:(