diff --git a/app/commands/bootcamp/solution/complete.rb b/app/commands/bootcamp/solution/complete.rb index 7560ab12c3..5986048150 100644 --- a/app/commands/bootcamp/solution/complete.rb +++ b/app/commands/bootcamp/solution/complete.rb @@ -17,7 +17,11 @@ def schedule_deferred_jobs! Bootcamp::UpdateUserLevel.defer(user) end - def user_project = Bootcamp::UserProject.for!(user, project) + def user_project + Bootcamp::UserProject.for!(user, project) + rescue ActiveRecord::RecordNotFound + Bootcamp::UserProject::Create.(user, project) + end delegate :user, :project, to: :solution end diff --git a/app/commands/bootcamp/user_project/create.rb b/app/commands/bootcamp/user_project/create.rb index 87704db48e..df6a5d6107 100644 --- a/app/commands/bootcamp/user_project/create.rb +++ b/app/commands/bootcamp/user_project/create.rb @@ -4,12 +4,12 @@ class Bootcamp::UserProject::Create initialize_with :user, :project def call - find_or_create.tap do |up| + create_or_find.tap do |up| Bootcamp::UserProject::UpdateStatus.(up) end end - def find_or_create + def create_or_find Bootcamp::UserProject.create!(user:, project:) rescue StandardError Bootcamp::UserProject.find_by!(user:, project:)