fix(member): optimize validation and fix logic order in details update#2475
Merged
olleolleolle merged 1 commit intocodebar:masterfrom Feb 11, 2026
Merged
Conversation
Problem: - member_params was called 6+ times per request (inefficient) - Validation was checking original params while attrs were modified - Confusing control flow made code hard to maintain Solution: - Call member_params once and reuse the result - Pass attrs to validation method instead of re-calling member_params - Validate BEFORE modifying attributes for clearer logic flow Performance: Reduced member_params calls from 6 to 1 per request Test: Added test to verify member_params is called only once
olleolleolle
approved these changes
Feb 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The member details update action had a significant performance issue and confusing validation logic:
member_paramswas being called 6+ times per request (severe performance issue)Solution
This PR fixes the performance issue and clarifies the logic:
member_paramsonce - Store result and reuse throughout the methodmember_paramsinternallyPerformance Impact
Before:
member_paramscalled 6 times per requestAfter:
member_paramscalled 1 time per requestThis is a 6x performance improvement for this controller action.
Test Coverage
Added new test
validates efficiently by calling member_params only oncethat:member_paramsto track call countAll existing tests pass, confirming no regressions.
Changes
app/controllers/member/details_controller.rb- Reordered validation and attribute modificationapp/controllers/concerns/member_concerns.rb- Updatedhow_you_found_us_selections_valid?to accept attrs parameterspec/controllers/member/details_controller_spec.rb- Added performance regression test