2
:私はこの入力から、このクエリどのようにsqueelでwhere条件を動的に処理するのですか?この入力から
Score.joins(:target_disability).where{ (target_disabilities.name == 'hearing') & (round(total_score) >= 1) }
を生成するために必要{ '聴覚' => 1} {=> 1、 'モビリティ' => 2 '聴覚'}であり、私が必要この生成:
Score.joins(:target_disability).where{ (target_disabilities.name == 'hearing') & (round(total_score) >= 1) | (target_disabilities.name == 'mobility') & (round(total_score) >= 2) }
をのように...どのようにこれは
を一般化することができますか?私の入力は時々3つのまたは4のキーを持っているので...いつかあなたのハッシュを仮定すると、1 ...
あなたは私のためにこれを見ることができますか? http://stackoverflow.com/questions/14654010/squeel-and-rails-dynamic-where-clause –