Skip to content

ExpenseReportsController#create: avoid destroying existing report#146

Merged
sorah merged 1 commit intomasterfrom
fix-expense-report-data-loss
Apr 2, 2026
Merged

ExpenseReportsController#create: avoid destroying existing report#146
sorah merged 1 commit intomasterfrom
fix-expense-report-data-loss

Conversation

@sorah
Copy link
Copy Markdown
Member

@sorah sorah commented Apr 2, 2026

build_expense_report on a has_one with dependent: :destroy deletes the existing record (cascading to line_items and submissions) before inserting. The RecordNotUnique rescue never fires because the old row is already gone. Check for an existing report first, and use ExpenseReport.create! directly to bypass has_one replacement.

build_expense_report on a has_one with dependent: :destroy deletes
the existing record (cascading to line_items and submissions) before
inserting. The RecordNotUnique rescue never fires because the old
row is already gone. Check for an existing report first, and use
ExpenseReport.create! directly to bypass has_one replacement.
@sorah sorah enabled auto-merge April 2, 2026 18:57
@sorah sorah added this pull request to the merge queue Apr 2, 2026
Merged via the queue into master with commit 06d9283 Apr 2, 2026
2 checks passed
@sorah sorah deleted the fix-expense-report-data-loss branch April 2, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant