Skip to content

Instantly share code, notes, and snippets.

@austindoeswork
Created January 29, 2019 18:36
Show Gist options
  • Save austindoeswork/8e28e311e82b1c24569bfb9b4f915c90 to your computer and use it in GitHub Desktop.
Save austindoeswork/8e28e311e82b1c24569bfb9b4f915c90 to your computer and use it in GitHub Desktop.
old_form_id = # OLD FORM ID
new_form_id = # NEW FORM ID
old_form = FormTemplate.find(old_form_id)
new_form = FormTemplate.find(new_form_id)
old_form.form_template_items.each do |old_item|
attributes = old_item.attributes
attributes.delete("id")
attributes["form_template_id"] = new_form_id
FormTemplateItem.where(attributes).first_or_create
end
Team.where(form_template_id: old_form_id).update_all(form_template_id: new_form_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment