If you check this link here, you can see the definition of references.
In short terms, the includes
will run a separate query to get all your posts
(in your example) instead of getting them every time you loop through a blog.
Now for references, of you want to add a where
condition on the posts
, you'll need to add it. In your case, you don't need to include it.
Small example:
blog = Blog.includes(:posts).where(uuid: params[:uuid])
-> will run a query to get the Blog from blogs
and a query to get all the posts
related to this blog.
In another case, like this: blog = Blog.includes(:posts).references(:posts).where(posts: { name: 'test' })
you'll have to use the references
or your where
condition will throw an error