2
我具有相关联的模型是这样的:导轨3关联急于负载VS相对关联
class Batch
has_many :logs
class Log
belongs_to :batch
我使用包括加载批次与原木:
b = Batch.includes(:logs)
哪个运行2个选择为预期的(批次和日志)。
然后我做
b.first.logs.first.batch
,这会触发另一批次的选择,即使他们实际上已经加载。 我想通过执行includes(:logs =>:batch)来“修复”它,但我仍然认为这里有些问题,因为相同的批次加载了两次。是什么赋予了?
Thx,从来没有注意到这一点! – stanley90