1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-11 22:24:21 +01:00
fab-manager/app/controllers/api/statuses_controller.rb

47 lines
999 B
Ruby
Raw Normal View History

2023-01-16 17:37:44 +01:00
# frozen_string_literal: true
# API Controller for resources of type Status
# Status are used to check Projects state
class API::StatusesController < ApplicationController
before_action :set_status, only: %i[update destroy]
before_action :authenticate_user!, only: %i[create update destroy]
def index
@statuses = Status.all
end
def create
authorize Status
@status = Status.new(status_params)
if @status.save
render json: @status, status: :created
else
render json: @status.errors, status: :unprocessable_entity
end
end
def update
authorize Status
if @status.update(status_params)
render json: @status, status: :ok
else
render json: @status.errors, status: :unprocessable_entity
end
end
def destroy
authorize Status
@status.destroy
head :no_content
end
private
def set_status
@status = Status.find(params[:id])
end
def status_params
params.require(:status).permit(:name)
2023-01-16 17:37:44 +01:00
end
end