-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 nested form always required? #1581
Comments
I have the same issue. My polymorphic "video_assets" model shows as "optional" but i can't save the parent because validation fails on "video_asset", saying it can't be blank although it is not required by any validation. |
I also have a similar issue. I have a has_one relation, which is optional. Since there is no validation on the related model, rails_admin creates a blank record when saving the parent model. Very irritating. The user should have to manually create the associated model as it works with has_many associations. If the has_one relation is compulsory, there would be no meaning in putting it in a separate model as it could just as well be attributes of the parent. |
Reject it if one of the main field is blank. There is no way for RailsAdmin to tell if the record is significant or not. |
Of course not... RailsAdmin shouldn't create the related model if I don't tell it to. That was the point. |
I have created a fork where I have rewritten how rails_admin handles has_one associations (I haven't created any specs yet though), https://github.com/baldursson/rails_admin/tree/optional-has-one Associated models with a has_one relation is not created by default now, it's instead up to the user to explicitly create it. I really do think this is how it should work. |
Fixed by #1632. |
I followed instructions for doing a has_one association and using the nested form approach @ https://github.com/sferik/rails_admin/wiki/Has-one-association. The nested form shows up fine in the parent model, however, the parent record doesn't save because the has_one nested form is always required to be filed out now. How do I make the has_one form optional?
The text was updated successfully, but these errors were encountered: