diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 70660053e..dc7546f82 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -213,7 +213,6 @@ class ProjectsController < ApplicationController next unless can_archive_project?(project) project.transaction do - project.project_folder = nil project.archive!(current_user) log_activity(:archive_project, project) counter += 1 diff --git a/app/models/project.rb b/app/models/project.rb index 9e5d003fc..6a6e8ebd9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -13,6 +13,7 @@ class Project < ApplicationRecord validates :visibility, presence: true validates :team, presence: true validate :project_folder_team, if: -> { project_folder.present? } + before_validation :remove_project_folder, on: :update, if: :archived_changed? belongs_to :created_by, foreign_key: 'created_by_id', @@ -330,4 +331,8 @@ class Project < ApplicationRecord errors.add(:project_folder, I18n.t('activerecord.errors.models.project.attributes.project_folder.team')) end + + def remove_project_folder + self.project_folder = nil if archived? + end end