On my views I have a partial that loops the comments and contains code
similar to this:
[code]
comment.comment_by.name
[/code]
So my question is:
If I don't put the include on the find method and let the views as
they are, does rails make a new query when it sees something like
comment.comment_by.name. And if that is the case, if I put the include
on the find, am I saving those queries from happening for each comment
later on?
On my views I have a partial that loops the comments and contains code
similar to this:
[code]
comment.comment_by.name
[/code]
So my question is:
If I don't put the include on the find method and let the views as
they are, does rails make a new query when it sees something like
comment.comment_by.name.
Yes. Rails will automatically query the database if you request an
association that is not already loaded.
And if that is the case, if I put the include
on the find, am I saving those queries from happening for each comment
later on?
Yes. You can also verify what SQL queries rails is executing by
looking in the log files.