Collapse profile creation to single method#6681
Conversation
**Why**: So that deactivation_reason can be assigned in initial creation of the profile, rather than as an immediate follow-on transaction. changelog: Internal, Optimization, Optimize identity verification profile database creation
|
I guess this could go one step further and try to eliminate the |
1. Applicant is now assigned in `before` block of the top-level method `describe` 2. Avoid calling create_profile_from_applicant_with_password twice
Looking at this closer, the activation of a profile is responsible for more than just setting the |
What if we just made |
So activation is centralized to the ProfileMaker and callsites must make an explicit choice #6681 (comment)
Is 8ae135e what you had in mind? It doesn't help with regards to consolidating database calls, but it does help centralize and make the flag more explicit. |
| def save_profile | ||
| profile = Profile.new(user: user, active: false) | ||
| def save_profile(active:, deactivation_reason: nil) | ||
| profile = Profile.new(user: user, active: false, deactivation_reason: deactivation_reason) |
There was a problem hiding this comment.
Note: This must be active: false and not active: active, since the activate call below would try to find an existing profile with active: true and incorrectly catch the profile which had just been created here.
Yup! Love it |
Context: #6634 (comment)
Why: So that deactivation_reason can be assigned in initial creation of the profile, rather than as an immediate follow-on transaction.