[TAN-7666] Allow clearing an idea's location via the edit form#13850
Merged
jinjagit merged 2 commits intoMay 13, 2026
Conversation
Collaborator
|
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.
Claude Code assisted.
The fix
location_point_geojsonas a scalar in addition to its existing nested-hash permit, so a client-sentnullis no longer silently dropped by strong-params and actually clears the column.IdeationFormsubmit time, forcelocation_point_geojsonto null whenlocation_descriptionis empty — without this the form would echo the originalPointback and the BE would just re-save it, even with the permit fix in place.ideas_update_spec.rb: admin sendsnullfor both attributes, both clear on the persisted record.Not covered
location_descriptionis gated onsubmittable_field_keys;location_point_geojsonis permitted unconditionally on the BE. Maybe worth aligning, or maybe there is a good reason for this, but out of scope in any case.A note on Rails params, scalars & nested hashes
In Rails strong-params, parameters are permitted in two shapes:
name: params.permit(:location_point_geojson). Rails accepts strings, numbers, booleans, nil, dates, etc. as scalars. A JSON object is not a scalar in this sense.params.permit(idea_complex_attributes: [:location_point_geojson, ...]) orparams.permit(location_point_geojson: [:type, coordinates: []]).When you only declare
location_point_geojsonas a nested hash permit (expecting{ type: "Point", coordinates: [...] }), strong-params evaluates whether the incoming value matches that hash shape. Anulldoesn't match a hash shape, so it gets silently dropped from the permitted params — the controller never sees the clear intent.Permitting it additionally as a scalar
(params.permit(:location_point_geojson)) tells strong-params "a bare primitive value at this key is also acceptable." Nownullsurvives the filter and reaches the model, where assigningnilactually clears the column. The two permits coexist: a hash payload flows through the nested permit, a null payload flows through the scalar permit.Changelog
Fixed