diff --git a/app/models/group/ortsgruppe.rb b/app/models/group/ortsgruppe.rb index 1fd3d839f..247cc050e 100644 --- a/app/models/group/ortsgruppe.rb +++ b/app/models/group/ortsgruppe.rb @@ -32,4 +32,8 @@ class Group::Ortsgruppe < Group mounted_attr :mitglied_termination_by_section_only, :boolean, default: false, null: false has_many :sac_section_membership_configs, dependent: :destroy, foreign_key: :group_id + + def active_sac_section_membership_config + @active_sac_section_membership_config ||= sac_section_membership_configs.active + end end diff --git a/app/resources/sac_cas/group_resource.rb b/app/resources/sac_cas/group_resource.rb index fdfade25a..3bbc09912 100644 --- a/app/resources/sac_cas/group_resource.rb +++ b/app/resources/sac_cas/group_resource.rb @@ -57,8 +57,8 @@ module SacCas::GroupResource attr = [prefix, suffix].join("_") extra_attribute attr.to_sym, :big_decimal, writable: false, sortable: false do - next unless @object.respond_to?(:sac_section_membership_configs) - @object.active_sac_section_membership_config.send(attr) + next unless @object.respond_to?(:active_sac_section_membership_config) + @object.active_sac_section_membership_config&.send(attr) end end end