ruby on rails joins VS includes

def A

  has_many B 比赛

end

 

def B

  belongs_to As  人

end

 

B.includes(As)

SQL语句

select b* from b 

select a* from where(b_id) in (上面语句中查询的结果集)

 

B.joins(As)

SQL语句

SELECT b* FROM b INNER JOIN a ON a.id = b.a_id

 

你可能感兴趣的:(ruby on rails)