Rails doesn't populate dynamic generated fields on error on posting

In our raols application we have a page where upon submit we save data
in db. On this page, we have some fields which are dynamically
generated and I see that in case of a validation error when page
reloads it doesn’t populate these fields with the values present upon
posting.

In controller we have the following method defined for populating it:

def
build_my_registration_type_memberships
@memberships =
[]
ListCache.my_registration_types.each do |
my_registration_type|
@memberships <<
MyRegistrationTypeMembership.find_or_initialize_by_my_id_and_my_registration_type_id(
@my.id,
my_registration_type.id )

end
end

In above method when my registration is opened in edit/view mode, it
shows the values using this @membership method. But on posting in case
of error it doesn’t reload this with correct information. So my
question is how could I repopulate @membership in case of an error on
posting?

Thanks for help.

adnan khan wrote in post #995336:

In our raols application we have a page where upon submit we save data
in db. On this page, we have some fields which are dynamically
generated and I see that in case of a validation error when page
reloads it doesn’t populate these fields with the values present upon
posting.

What do you mean by your fields being dynamically generated? It’s the
normal case for all the fields, along with the form itself, to be
dynamically generated in Rails applications. That’s what form helper
methods do.

Do you mean you’re adding them with JavaScript? If that’s the case then
JavaScript would be needed to manage their contents as well.