Files
subtle-storm/app/services/tasks/create.rb
T
2025-07-14 01:31:08 +03:00

23 lines
520 B
Ruby

# frozen_string_literal: true
module Tasks
class Create < ApplicationService
attribute :project_id, :integer
attribute :title, :string
attribute :description, :string
validates :project_id, :title, presence: true
delegate :model_name, to: Task
attr_reader :project, :task
def perform
@project = Project.find(project_id)
@task = @project.tasks.build(title:, description:, number: @project.next_task_number)
@task.save.tap { @errors = @task.errors }
end
end
end