Created
January 29, 2019 18:36
-
-
Save austindoeswork/8e28e311e82b1c24569bfb9b4f915c90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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