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

has_one should have automatic validator #373

Open
BrucePerens opened this issue May 23, 2020 · 2 comments
Open

has_one should have automatic validator #373

BrucePerens opened this issue May 23, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@BrucePerens
Copy link

Given model A which has_one model B, not nilable; and model B which belongs_to model A, the foreign key is in Model B. Model A does not automatically validate that Model B exists before it is saved, but it should. For context, see https://gitter.im/luckyframework/Lobby?at=5ec87bab2280c80cbfc19651

@jwoertink jwoertink added the bug Something isn't working label May 23, 2020
@BrucePerens
Copy link
Author

Also, has_one doesn't get an attribute in the save operation.

@BrucePerens
Copy link
Author

This validator needs to run before commit, and after any after-save callbacks have run. In general, management of dependent records happens in after-save callbacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants