has_one nested form always required? #1581

axsuul opened this Issue Mar 27, 2013 · 6 comments


None yet

5 participants

axsuul commented Mar 27, 2013

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?

drale2k commented Apr 14, 2013

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.

@mshibuya mshibuya closed this Mar 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment