app/forms/waste_carriers_engine/conviction_details_form.rb
def list_of_people_to_keep
      people = []

      transient_registration.key_people.each do |person|
        # We need to copy the person before adding to the array to avoid 'conflicting modifications' Mongo error (10151)
        people << person.clone
      end

      people
    end
# Adding the new person directly to @transient_registration.key_people immediately updates the object,
# regardless of validation. So instead we copy all existing people into a new array and modify that.
Adding the new person directly to @transient_registration.key_people immediately updates the object,
regardless of validation. So instead we copy all existing people into a new array and modify that.
Adding the new person directly to @transient_registration . key_people immediately updates the object regardless of validation . So instead we copy all existing people into a new array and modify that .
def list_of_people_to_keep
      people = []
      transient_registration.key_people.each do |person|
        people << person.clone
      end
      people
    end
def list_of_people_to_keep people = [ ] transient_registration . key_people . each do | person | people << person . clone end people end
Adding the new person directly to @transient_registration.key_people immediately updates the object,
regardless of validation.
Adding the new person directly to @transient_registration . key_people immediately updates the object regardless of validation .
# We need to copy the person before adding to the array to avoid 'conflicting modifications' Mongo error (10151)