Hi,
I’m trying to reduce my queries to the database so i use includes, but
there is produced a query every time and i can’t see an improvement.
What does i’m doing wrong?
In controller:
@matches = @stage.matches.find(:all,:include =>
[:team_1,:team_2, :match_tips])
In view:
<% @matches.each do |match| %>
<% if @tipped_matches.include? match %>
<% tip = match.match_tips.find_by_user_id(current_user.id) %>
…
So the third line will produce every turn through the loop a query,
thats not good, how can i avoid that?