diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aeeb4e2f3..3ff9012ad6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### Fixed +- Fixed a bug in the deep copy of plans where the old identifier was being copied into the new plan. We now copy the generated id of the new plan to the identifier field. + ## v4.2.0 **Note this upgrade is mainly a migration from Bootstrap 3 to Bootstrap 5.** diff --git a/app/models/plan.rb b/app/models/plan.rb index 7626bba207..f2fb6a2901 100644 --- a/app/models/plan.rb +++ b/app/models/plan.rb @@ -255,6 +255,9 @@ def self.deep_copy(plan) plan_copy.title = "Copy of #{plan.title}" plan_copy.feedback_requested = false plan_copy.save! + # Copy newly generated Id to the identifier + plan_copy.identifier = plan_copy.id.to_s + plan.save! plan.answers.each do |answer| answer_copy = Answer.deep_copy(answer) answer_copy.plan_id = plan_copy.id