Statuses in task - db field and forms

This commit is contained in:
2025-10-25 17:41:06 +03:00
parent b08468568b
commit ba2aad93af
12 changed files with 86 additions and 13 deletions
+8 -5
View File
@@ -5,18 +5,21 @@ module Tasks
attribute :project_id, :integer
attribute :title, :string
attribute :description, :string
attribute :status_id, :integer
validates :project_id, :title, presence: true
delegate :model_name, to: Task
attr_reader :project, :task
attr_reader :task
def project
@project ||= Project.find(project_id)
end
def perform
@project = Project.find(project_id)
@task = @project.tasks.build(title:, description:, number: @project.next_task_number)
@task.save.tap { @errors = @task.errors }
@task = project.tasks.build(title:, description:, status_id:, number: @project.next_task_number)
save @task
end
end
end
+2 -1
View File
@@ -5,6 +5,7 @@ module Tasks
attribute :id, :integer
attribute :title, :string
attribute :description, :string
attribute :status_id, :integer
validates :title, presence: true
@@ -15,7 +16,7 @@ module Tasks
def perform(task)
@task = task
@id = task.id
@task.assign_attributes(title:, description:)
@task.assign_attributes(title:, description:, status_id:)
save @task
end
end