I have a model say “site” and another model “equipment”.
In the Site form I can attach equipment dynamically in the form and
the equipment has attributes in the :through table.
Is there a way to validate the equipment attributes ONLY when the SITE
form has been completed?
I do an ajax to add the equipment. The models are not nested.
I would say that in your case the easy way is to not nest the forms.
Just return in your post the list of equipments and the site. In your
controller, save or update the site, then try to save each equipment.
Make sure you reassign your instance variables properly.
If you want to keep them nested and do this I would suggest submit the
site the first time ‘add equipment’ or whatever button is pressed and
reload the page or AJAX it up in the background.