Files
canine/app/controllers/projects/services_controller.rb
Chris 26dc5c7f74 wip
2025-11-13 21:49:09 -05:00

52 lines
1.4 KiB
Ruby

class Projects::ServicesController < Projects::BaseController
before_action :set_project
before_action :set_service, only: %i[update destroy]
def index
@services = @project.services.order(:name)
end
def new
@service = @project.services.build
end
def create
result = Services::Create.call(@project.services.build(service_params), params)
if result.success?
redirect_to project_services_path(@project), notice: "Service will be created on the next deploy."
else
redirect_to project_services_path(@project), alert: "Service could not be created. #{result.message.to_s.humanize}"
end
end
def show
@service = @project.services.find(params[:id])
@tab = params[:tab] || "overview"
render partial: "projects/services/show", locals: { service: @service, tab: @tab }, layout: false
end
def update
result = Services::Update.execute(service: @service, params: params)
if result.success?
redirect_to project_services_path(@project), notice: "Service will be updated on the next deploy."
else
redirect_to project_services_path(@project), alert: "Service could not be updated."
end
end
def destroy
@service.destroy
redirect_to project_services_path(@project), notice: "Service will be removed on the next deploy."
end
private
def set_service
@service = @project.services.find(params[:id])
end
def service_params
Service.permitted_params(params)
end
end