current_user
Mongoid モデルがあり、モデルとリアルタイムで計算されたスコアによって結果を並べ替えたいと思います。インスタンスThing
メソッドがあるとしますmatch_score
:
def match_score(user) #can be user object too
score = 100
score -= 5 if user.min_price && !(price < user.min_price)
score -= 10 if user.max_price && !(price > user.max_price)
#... bunch of other factors...
return [score, 0].max
end
特定のユーザーに対して返された値でクエリの結果を並べ替えることができますか?