Statuses in task - db field and forms
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user