使用 squeel,我能够生成以下请求
Payment.joins(:account => :preference).where({:account => {:preference => {:currency => :currency } } }).to_sql
=> SELECT "payments".* FROM "payments" INNER JOIN "accounts" ON "accounts"."id" = "payments"."account_id" INNER JOIN "preferences" ON "preferences"."account_id" = "accounts"."id" WHERE "preferences"."currency" = "preferences"."currency"
然而,如何获得?(资本变动)
=> SELECT "payments".* FROM "payments" INNER JOIN "accounts" ON "accounts"."id" = "payments"."account_id" INNER JOIN "preferences" ON "preferences"."account_id" = "accounts"."id" WHERE "preferences"."currency" = "PAYMENTS"."currency"
如果解决方案在 meta_where 上也能正常工作,那就更好了 ;-)