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

Automatically pick up presence validators for default belongs_to association #654

Merged
merged 4 commits into from
Aug 15, 2022

Conversation

donv
Copy link
Collaborator

@donv donv commented Aug 10, 2022

Automatically pick up presence validators for an association for a given ID attribute.

This enables form validation with messages for default belongs_to associations since Rails 5.

@donv donv requested review from thimo and lcreid August 10, 2022 16:36
@donv donv force-pushed the validate_associations branch from 010df71 to 7b9c014 Compare August 10, 2022 16:41
@donv donv self-assigned this Aug 10, 2022
Copy link
Contributor

@lcreid lcreid left a comment

Choose a reason for hiding this comment

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

This is a great find, and a nice solution. I'm hoping it's not too hard to make it more general, for when the foreign key column name doesn't match Rails' conventions.

It would be nice to see a test to show what the new code does.

@UweKubosch
Copy link
Contributor

I'll do at least an entry in the README to see what the code does.

Copy link
Contributor

@lcreid lcreid left a comment

Choose a reason for hiding this comment

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

I won't merge this in case you want to do the README in this PR. Otherwise, you can merge this and do another PR.

@donv
Copy link
Collaborator Author

donv commented Aug 14, 2022

Hey good people! I added the fully generalized version and added a section in the README displaying the resulting code.

Please have a look. Squash and merge if it looks good.

@donv
Copy link
Collaborator Author

donv commented Aug 14, 2022

Oh, wait! One more fix needed!

@donv
Copy link
Collaborator Author

donv commented Aug 14, 2022

Now, go!

@lcreid lcreid merged commit 456dbc8 into main Aug 15, 2022
@donv donv deleted the validate_associations branch August 15, 2022 08:29
@donv donv mentioned this pull request May 19, 2023
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.

None yet

3 participants