Fix members#new 500 from nil MembershipPricing amounts - #180
Merged
Merged
Conversation
MembershipPricing#add called round_to_five_cents on nil when the registration form asked for activity participations but no delivery cycle could be resolved. Treat missing price parts as zero and skip activity/extra math without a cycle or delivery count. Co-authored-by: Thibaud Guillaume-Gentil <thibaud@thibaud.gg>
thibaudgg
force-pushed
the
cursor/membership-pricing-nil-round-bb3e
branch
from
September 15, 2026 15:59
30001db to
9def02f
Compare
thibaudgg
marked this pull request as ready for review
September 15, 2026 16:00
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.
Fixes a recurring production 500 on the public member registration form when the live pricing turbo-frame refreshes.
AppSignal
ActionView::Template::Errorwrappingundefined method 'round_to_five_cents' for nilMembers::MembersController#new(GET /new)seminterraApp frames:
app/models/membership_pricing.rb#add/#prices/#present?app/views/members/members/_pricing.html.erb:3app/views/members/members/new.html.erb:95-97Root cause
The pricing partial builds
MembershipPricingfrom the registration form params (turbo-frame refresh onGET /new).The latest failing request had:
waiting_basket_size_idsetwaiting_basket_price_extraset (1.0)waiting_activity_participations_demanded_annuallyset (10)waiting_depot_idsetwaiting_delivery_cycle_idblank#activity_participations_pricesmaps over resolved delivery cycles and returns[counts.min, counts.max]. When no cycle can be resolved (blank cycle id and a depot without kept cycles, or no depot/cycles at all), that map is empty and the method returns[nil, nil].#addthen callsround_to_five_centson nil and the pricing frame 500s.This is not a missing basket/depot fee column. Those prices are non-null. The nil is the computed activity-participation price range when there is no delivery-cycle context.
Fix
[0, 0]for activity (and complement) prices when no delivery cycle can be resolved, instead of[nil, nil].0before rounding, so#addcannot 500.Valid form data with a resolvable cycle is unchanged (existing pricing tests still pass). An incomplete selection now shows no price rather than a 500.
Tests
test/models/membership_pricing_test.rbcovers the production-like params (activity + extra + selected depot + blank cycle, depot with no cycles) and the no-depot/no-cycle case.Do not merge, deploy, or close the AppSignal incident from this PR.