Skip to content

Commit d8f8978

Browse files
committed
Refactor / use ActiveRecord association operator
Using << here replaces manual foreign key assignment as well as the explicit save call.
1 parent 4b25e4a commit d8f8978

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

app/models/plan.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ def self.deep_copy(plan)
259259
plan_copy.identifier = plan_copy.id.to_s
260260
plan.answers.each do |answer|
261261
answer_copy = Answer.deep_copy(answer)
262-
answer_copy.plan_id = plan_copy.id
263-
answer_copy.save!
262+
plan_copy.answers << answer_copy
264263
end
265264
plan.guidance_groups.each do |guidance_group|
266265
plan_copy.guidance_groups << guidance_group if guidance_group.present?

0 commit comments

Comments
 (0)