diff --git a/app/models/match.rb b/app/models/match.rb index 69910b8..0514cdf 100755 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -90,7 +90,7 @@ class Match < ActiveRecord::Base scope :of_contester, -> (contester) { where("contester1_id = ? OR contester2_id = ?", contester.id, contester.id) } scope :of_user, -> (user) { includes(:matchers).where("matchers.user_id = ?", user.id) } scope :of_team, -> (team) { includes({:contester1 => :team, :contester2 => :team}).where("teams.id = ? OR teams_contesters.id = ?", team.id, team.id) } - scope :of_userteam, -> (user, team) { includes({:matchers => {:contester => :team}}).where("teams.id = ? AND matchers.user_id = ?", team.id, user.id) } + scope :of_userteam, -> (user, team) { eager_load({:matchers => {:contester => :team}}).where("teams.id = ? AND matchers.user_id = ?", team.id, user.id) } scope :within_time, -> (from, to) { where("match_time > ? AND match_time < ?", from.utc, to.utc) } scope :around, -> (time) { where("match_time > ? AND match_time < ?", time.ago(MATCH_LENGTH).utc, time.ago(-MATCH_LENGTH).utc) } scope :after, -> (time) { where("match_time > ? AND match_time < ?", time.utc, time.ago(-MATCH_LENGTH).utc) } diff --git a/app/views/matches/_list.html.erb b/app/views/matches/_list.html.erb index d5b48eb..dd89a55 100644 --- a/app/views/matches/_list.html.erb +++ b/app/views/matches/_list.html.erb @@ -11,7 +11,7 @@ Maps <% end %> Score - <% if matches.first and matches.first.contest.contest_type == Contest::TYPE_LADDER %> + <% if matches&.first.contest.contest_type == Contest::TYPE_LADDER %> Points <% end %>