From bcac28d4ff47061d8440c075497b75302020cedb Mon Sep 17 00:00:00 2001 From: Tocho Tochev Date: Sat, 1 Jun 2024 12:32:12 +0300 Subject: [PATCH] Fix volunteer counts shown for a team (#46) Before this change the count of volunteers in a team was not in sync with the filters applied. ![image](/attachments/0a3a0c5c-f3c2-4ef4-89d7-0bcf1fb9302d) After the change: ![image](/attachments/b88719f6-fadf-4f07-b4d4-985533b0ea2f) BTW I feel that we will end up refactoring the relation at some point in the future. Reviewed-on: https://git.openfest.org/Site/clarion/pulls/46 Co-authored-by: Tocho Tochev Co-committed-by: Tocho Tochev --- app/models/volunteer_team.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/volunteer_team.rb b/app/models/volunteer_team.rb index 4105cee..bc3e776 100644 --- a/app/models/volunteer_team.rb +++ b/app/models/volunteer_team.rb @@ -1,6 +1,7 @@ class VolunteerTeam < ActiveRecord::Base belongs_to :conference - has_and_belongs_to_many :volunteers + has_many :volunteers, inverse_of: :volunteer_team + has_and_belongs_to_many :supporters, class_name: "Volunteer", inverse_of: :additional_volunteer_teams validates :name, presence: true validates :color, presence: true, format: {with: /\A#?[a-f0-9]{6}\z/i}