Untie statuses from the project directly (tie to workflows)

This commit is contained in:
2026-03-21 15:35:09 +02:00
parent 218e8a750e
commit eb9f3e982c
10 changed files with 31 additions and 17 deletions
+1 -1
View File
@@ -7,8 +7,8 @@ class Project < ApplicationRecord
validates :code, exclusion: { in: %w[new] }, uniqueness: true, format: { with: /\A[a-z][a-z0-9]{1,}\z/ }
has_many :tasks, dependent: :restrict_with_exception
has_many :task_statuses, dependent: :destroy
has_many :workflows, dependent: :destroy
has_many :task_statuses, through: :workflows
has_rich_text :description
+2 -2
View File
@@ -1,12 +1,12 @@
# frozen_string_literal: true
class TaskStatus < ApplicationRecord
belongs_to :project
belongs_to :workflow
has_one :project, through: :workflow
enum :category, { backlog: 100, analysis: 1000, development: 20_000, fulfillment: 60_000 }
validates :name, presence: true, uniqueness: { scope: :project }
validates :name, presence: true, uniqueness: { scope: :workflow }
validates :category, presence: true
validate :associations_should_have_same_project
+1 -1
View File
@@ -4,7 +4,7 @@ class Workflow < ApplicationRecord
belongs_to :project
has_many :tasks, dependent: :restrict_with_exception
has_many :statuses, class_name: 'TaskStatus', dependent: :restrict_with_error
has_many :task_statuses, dependent: :restrict_with_error
enum :icon, { task: 'task', warning: 'warning' }, default: 'task', scopes: false
enum :color, { blue: 'blue', gray: 'gray', yellow: 'yellow', red: 'red' }, default: 'gray', scopes: false