来自 django,我们有一个叫做 select_related 的东西,它在执行查询时进行连接,这样相关对象的数据也会被获取。
例如
# rails + select_related
p = Person.where(job: 1).select_related("job_name")
# so the return query list has objects that
# can call person.job.job_name without another query
# because selected_related did a join on jobs table
你如何在 rails/activerecord 中做到这一点?