mercredi 24 août 2016

Includes association

How can I load this from fewer queries?

Current code; Controller;

@players = @season.players.includes(:stats)

Views;

<% @players.each do |player| %>
    <%= player.stats.where(season: @season).each do |stat| %>
    <% end %>
<% end %>

Thank you.

Aucun commentaire:

Enregistrer un commentaire