File tree Expand file tree Collapse file tree 4 files changed +11
-7
lines changed
models/better_together/geography Expand file tree Collapse file tree 4 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ def respond_to_create_failure(format) # rubocop:todo Metrics/MethodLength
5656
5757 # GET /joatu/agreements/:id
5858 def show
59- mark_notifications_read_for_record ( @joatu_agreement )
59+ mark_notifications_read_for_record_id ( @joatu_agreement . id )
6060 super
6161 end
6262
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ def mark_notification_as_read(id)
4545 end
4646
4747 def mark_record_notification_as_read ( id )
48- mark_notifications_read_for_record ( Struct . new ( id : id ) , recipient : helpers . current_person )
48+ mark_notifications_read_for_record_id ( id )
4949 end
5050 end
5151end
Original file line number Diff line number Diff line change @@ -5,12 +5,12 @@ module BetterTogether
55 module NotificationReadable
66 extend ActiveSupport ::Concern
77
8- # Marks notifications (for the current person) as read for events bound to a record
8+ # Marks notifications (for the current person) as read for events bound to a record ID
99 # via Noticed::Event#record_id (generic helper used across features).
10- def mark_notifications_read_for_record ( record , recipient : helpers . current_person )
11- return unless recipient && record . respond_to? ( :id )
10+ def mark_notifications_read_for_record_id ( record_id , recipient : helpers . current_person )
11+ return unless recipient && record_id . present?
1212
13- event_ids = Noticed ::Event . where ( record_id : record . id ) . select ( :id )
13+ event_ids = Noticed ::Event . where ( record_id : record_id ) . select ( :id )
1414
1515 Noticed ::Notification
1616 . where ( recipient :)
Original file line number Diff line number Diff line change @@ -197,11 +197,15 @@ def self.available_buildings_for(context = nil) # rubocop:todo Metrics/MethodLen
197197 private
198198
199199 def mark_for_destruction_if_empty
200+ # Only mark for destruction if this is a persisted nested record that becomes empty
201+ # Don't auto-mark new records for destruction as they should validate normally
202+ return unless persisted?
203+
200204 name_blank = name . blank?
201205 location_blank = location . blank?
202206
203207 # If both the simple name and structured location are blank, mark for destruction
204- # for both new and persisted records so validations won't block form submission.
208+ # for persisted records so accepts_nested_attributes_for with allow_destroy will remove them
205209 mark_for_destruction if name_blank && location_blank
206210 end
207211
You can’t perform that action at this time.
0 commit comments