Fix: NoMethodError (MAYBE-MARKETING-3X) #272
Open
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.
The error occurs because the
blank?
method is trying to callzero?
directly on potentially nil values. While the attributes have default values of 0.0 defined in the class, there are scenarios where these values could still be nil, such as during form submission with invalid or missing data.The original intent of the
blank?
method was to check if all the key financial inputs (desired home price, down payment, income, interest rate, and debt payments) are effectively empty/zero, likely to determine if the user has entered any meaningful data yet. This is used in the view to show either a blank slate message or the calculated results.The fix converts each value to a float using
to_f
before checking if it's zero. This is safer because:nil.to_f
returns 0.0 instead of raising an errorThe change makes the code more resilient while maintaining the same logical behavior that was intended in the original implementation.
Error Details
Summary:
Stacktrace:
Tip
You can make revisions or ask questions of Revise.dev by using
/revise
in any comment or review!/revise Add a comment above the method to explain why we're making this change.
/revise Why did you choose to make this change specifically?
Important
If something doesn’t look right, click to retry this interaction.
Quick links: View in Sentry • View in Revise