Tasks display

This commit is contained in:
2025-07-12 17:50:56 +03:00
parent 42d45853ff
commit 4f5b9dcf89
12 changed files with 120 additions and 7 deletions
+20
View File
@@ -1,3 +1,5 @@
# frozen_string_literal: true
class Task < ApplicationRecord
belongs_to :project
@@ -5,4 +7,22 @@ class Task < ApplicationRecord
validates :number, numericality: { greater_than: 0 }
has_rich_text :description
def to_param
return full_number if association(:project).loaded?
super
end
def full_number
"#{project.code.upcase}-#{number}"
end
def self.find_by_full_number_or_id!(number_or_id)
return find!(number_or_id) if number_or_id.is_a?(Numeric) || number_or_id =~ /\A\d+\z/
project_code, number = number_or_id.split('-')
project = Project.find_by!(code: project_code.downcase)
find_by!(project:, number:)
end
end