Skip to content

[TAN-7666] Allow clearing an idea's location via the edit form#13850

Merged
jinjagit merged 2 commits into
masterfrom
TAN-7666-bugfix-idea-location-can-be-removed-via-edit
May 13, 2026
Merged

[TAN-7666] Allow clearing an idea's location via the edit form#13850
jinjagit merged 2 commits into
masterfrom
TAN-7666-bugfix-idea-location-can-be-removed-via-edit

Conversation

@jinjagit
Copy link
Copy Markdown
Contributor

@jinjagit jinjagit commented May 12, 2026

Claude Code assisted.

The fix

  • BE: permit location_point_geojson as a scalar in addition to its existing nested-hash permit, so a client-sent null is no longer silently dropped by strong-params and actually clears the column.
  • FE: at IdeationForm submit time, force location_point_geojson to null when location_description is empty — without this the form would echo the original Point back and the BE would just re-save it, even with the permit fix in place.
  • Regression spec in ideas_update_spec.rb: admin sends null for both attributes, both clear on the persisted record.

Not covered

  • Asymmetric field gating. location_description is gated on submittable_field_keys; location_point_geojson is permitted unconditionally on the BE. Maybe worth aligning, or maybe there is a good reason for this, but out of scope in any case.
  • Historic records with point-but-no-description. Some are possibly legitimate (e.g. bulk import). Cleanup needs a domain decision rather than a blanket rule. Also, nobody is asking for a cleanup of existing data.

A note on Rails params, scalars & nested hashes

In Rails strong-params, parameters are permitted in two shapes:

  1. Scalar — a single primitive value at a top-level key. You permit it by 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.
  2. Nested hash — a structured value under a key. You permit it by passing a hash spec: params.permit(idea_complex_attributes: [:location_point_geojson, ...]) or params.permit(location_point_geojson: [:type, coordinates: []]).

When you only declare location_point_geojson as a nested hash permit (expecting { type: "Point", coordinates: [...] }), strong-params evaluates whether the incoming value matches that hash shape. A null doesn'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." Now null survives the filter and reaches the model, where assigning nil actually 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

  • [TAN-7666] Allow clearing an idea's location via the edit form

@jinjagit jinjagit self-assigned this May 12, 2026
@notion-workspace
Copy link
Copy Markdown

@jinjagit jinjagit requested a review from IvaKop May 12, 2026 15:55
@cl-dev-bot
Copy link
Copy Markdown
Collaborator

Messages
📖 Changelog provided 🎉
📖 Notion issue: TAN-7666
📖

Run the e2e tests

📖 Check translation progress

Generated by 🚫 dangerJS against 52dadb2

Copy link
Copy Markdown
Contributor

@IvaKop IvaKop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 🚀

@jinjagit jinjagit merged commit 6c998d7 into master May 13, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants