I have these fields in my form:
= f.fields_for :parts do |builder|
= builder.input :body, label: builder.object.another_relation.description, required: false
In the main model, I have this check:
validates_associated :parts
In the parts model, I have this check:
validates :body, presence: true
It works well. When I leave some part empty and try to create a model, the form displays again with the correct error messages.
But in the logs, I see that the label requests a database for each part, so I will need to download it.
How?
This was my attempt:
= f.fields_for :parts, f.object.parts.includes(:question_part) do |builder|
= builder.input :body, label: builder.object.another_relation.description, required: false
This desire loads the relationship successfully, but when I leave some field empty and try to create a model, the form is re-displayed with all parts empty and without errors. I think this is normal, as I force fields_for to load fields from this collection that I am passing.
Does anyone know how to solve this?