Sorry about the previous message I accidentally sent it before
I have a really quick question on the number of SQL calls I am seeing in
my development log when it comes to associations. This may just be an
environment issue, but I could not find an answer.
If I have a belongs_to association for books to a library for example.
class Library < ActiveRecord::Base
class Book < ActiveRecord::Base
If I am iterating over a collection of books in a view like so,
<% for b in @books %>
<%=h b.name %>,
<%= b.library.name %>
<%= b.library.city %>, <%= b.library.state %>
<% end %>
For each time through the loop there are 3 SQL call for the Library
information. One for each of the outputs where the Library is
referenced. Is this how this is supposed to work? Again, this is all
in a development environment, does the production behave differently?
Or, is there some kind of caching mechanism I am not taking advantage