LoginSignup
1
0

More than 5 years have passed since last update.

railsで関連モデルで検索したい、include where joins merge

Posted at

毎回忘れて悩む関連モデル検索を手短にまとめる

Userの中でProfileactivetrueの人だけ探したい。

mergeを使って条件を指定する。

search_result.joins(:profile).merge(Profile.where(active: true))
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0