mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-29 03:01:58 +08:00
Remove project_folder in callback
This commit is contained in:
parent
3ad14e06b2
commit
485aa0d541
2 changed files with 5 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue