Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warnings on belongs_to presence validation field mismatch #468

Merged
merged 2 commits into from
Feb 16, 2024

Conversation

peteryates
Copy link
Member

@peteryates peteryates commented Jan 30, 2024

Add warning on Rails relationship presence checks

This problem has occurred since Rails added default validation to Rails' belongs_to relationships in version 6.

Usually when creating forms we set relationships using the foreign key column, i.e. department_id, not the department relationship
attribute itself .

This mismatch causes errors on the object to be reported in the error summary but they won't link properly to the input because it's mapped to a different field.

Solving the problem itself is complex so this is a tentative first step and adds warnings to the guide.

It's really hard to concisely say what's going on, any feedback on wording welcome.

Refs #411

Changes

  • Add RedCarpet markdown rendering to the guide
  • Add warning on Rails relationship presence checks

Preview

(possible misuse of notification banner component 🚨)

image

Copy link

netlify bot commented Jan 30, 2024

Deploy Preview for govuk-form-builder ready!

Name Link
🔨 Latest commit cf28df8
🔍 Latest deploy log https://app.netlify.com/sites/govuk-form-builder/deploys/65bfd482f3beeb0007153c55
😎 Deploy Preview https://deploy-preview-468--govuk-form-builder.netlify.app/form-elements/checkboxes
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

This problem has occurred since Rails added default validation to Rails'
belongs_to relationships in version 6.

Usually when creating forms we set relationships using the foreign key
column, i.e. `department_id`, not the `department` relationship
attribute itself .

This mismatch causes errors on the object to be reported in the error
summary but they won't link properly to the input because it's mapped to
a different field.

Solving the problem itself is complex so this is a tentative first step
and adds warnings to the guide.
@peteryates peteryates force-pushed the add-warnings-on-belongs-to-presence-field-mismatch branch from 9f401b3 to cf28df8 Compare February 4, 2024 18:16
@peteryates peteryates marked this pull request as ready for review February 16, 2024 14:33
@peteryates peteryates merged commit b6f12b3 into main Feb 16, 2024
17 checks passed
@peteryates peteryates deleted the add-warnings-on-belongs-to-presence-field-mismatch branch February 16, 2024 14:33
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.

1 participant