Skip to content

Commit afe2d63

Browse files
danhalsonCopilot
andauthored
Create the code after_create to ensure it rolls back the transaction if the code fails
This is really an edge case, but because of that in the unlikely case it happens we're better off erroring and fixing it. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 35bcce7 commit afe2d63

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

app/models/school.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class School < ApplicationRecord
5252
before_save :format_uk_postal_code, if: :should_format_uk_postal_code?
5353

5454
# TODO: Remove the conditional once the feature flag is retired
55-
after_commit :generate_code!, on: :create, if: -> { FeatureFlags.immediate_school_onboarding? }
55+
after_create :generate_code!, if: -> { FeatureFlags.immediate_school_onboarding? }
5656

5757
def self.find_for_user!(user)
5858
school = Role.find_by(user_id: user.id)&.school || find_by(creator_id: user.id)

0 commit comments

Comments
 (0)