Order.includes(:user) 可以解决 N+1 查询,但是如果再查询 user 关联的 company, 怎么解决?
eg:
<%= order.user.name %> <%= order.user.company.name %>
Order.includes(:user => :campany)
Order.includes(:user => :company) +1
#1 楼 @hooopo 谢谢!
或者这样:Order.includes(user: [:campany])
dhh 说套娃缓存好