Add targeted_account_notes association to simplify usage (#35540)

This commit is contained in:
Matt Jankowski authored and GitHub committed 2026-01-23 16:35:19 +00:00
1 parent c36db57ace
commit 29ec2cd186
5 files changed
+14 -10

No files matched your search

@@ -9,9 +9,9 @@ class Api::V1::Accounts::NotesController < Api::BaseController
def create
if params[:comment].blank?
AccountNote.find_by(account: current_account, target_account: @account)&.destroy
current_account.account_notes.find_by(target_account: @account)&.destroy
else
@note = AccountNote.find_or_initialize_by(account: current_account, target_account: @account)
@note = current_account.account_notes.find_or_initialize_by(target_account: @account)
@note.comment = params[:comment]
@note.save! if @note.changed?
end