I have this code in a view:
<% for topic in @topics %>
<%= topic.id %> <%= topic.dr_title %>
<% for doc in topic.child_documents %>
<%= doc.dr_title %>
<% doc = nil %> <% end %> </ul>
<% end %>
Though the topic titles and IDs display correctly, the child documents
for every topic are the same (the ones belonging to the first topic). In
other words, I expect an SQL query to be run each time through the inner
loop, and it is, but it is always using the same topic id (that of the
first topic in the loop).
The habtm for child_documents defined in my model uses a custom
finder_sql which uses the id variable for the topic id. Could this
somehow not be populated correctly?
I can make the code work using other methods, but I’m wondering why this