Skip to content

Commit d4a9b83

Browse files
committed
Fix TeamLocation <> PatientLocation association
Rails doesn't provide a way to reference the source object directly (through `it`) in a through association scope.
1 parent 675d557 commit d4a9b83

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

app/models/team_location.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ class ActiveRecord_Relation < ActiveRecord::Relation
4444
has_many :sessions
4545

4646
has_many :patient_locations,
47-
-> { where(academic_year: it.academic_year) },
47+
->(team_location) do
48+
where(academic_year: team_location.academic_year)
49+
end,
4850
through: :location
4951

5052
validate :subteam_belongs_to_team

0 commit comments

Comments
 (0)