0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Railsで複雑なeager_loadを行いたいときの図解メモ

Posted at

はじめに

この記事は2021年9月にまとめていた「細かいつまずいたことをメモしておく(9月編)をそれぞれ投稿した内容になります
解決方法が最新でない可能性もありますのでご了承ください

テーブルの結合パターン

以下の関係のテーブルを結合する

パターン1

A ⇔ B ⇔ C
B.eager_load(:A, :C)

パターン2

A ⇔ B ⇔ C
     ↕
   D
A.eager_load([{ B: [:C, :D] }

パターン3

A ⇔ B ⇔ D
↕    ↕
C  E
A.eager_load([{B: [:D, :E]}, :C])
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?