2024-10-27 21:42:45 +00:00
|
|
|
# Copyright (C) 2024 Manuel Bustillo
|
|
|
|
|
2024-07-25 10:47:49 +02:00
|
|
|
require 'csv'
|
|
|
|
|
2024-07-11 20:08:26 +02:00
|
|
|
class GuestsController < ApplicationController
|
|
|
|
def index
|
2024-11-16 02:16:19 +01:00
|
|
|
render json: Guest.all.includes(:group)
|
|
|
|
.joins(:group)
|
|
|
|
.order('groups.name' => :asc, name: :asc)
|
|
|
|
.as_json(only: %i[id name status], include: { group: { only: %i[id name] } })
|
2024-07-11 20:08:26 +02:00
|
|
|
end
|
|
|
|
|
2024-11-17 11:47:12 +01:00
|
|
|
def create
|
|
|
|
Guest.create!(params.require(:guest).permit(:name, :group_id, :status))
|
|
|
|
render json: {}, status: :created
|
|
|
|
end
|
|
|
|
|
2024-11-11 07:43:42 +01:00
|
|
|
def update
|
2024-11-17 17:07:29 +01:00
|
|
|
Guest.find(params[:id]).update!(params.require(:guest).permit(:name, :status))
|
2024-10-27 14:03:13 +01:00
|
|
|
render json: {}, status: :ok
|
|
|
|
end
|
2024-11-17 18:24:43 +01:00
|
|
|
|
|
|
|
def destroy
|
|
|
|
Guest.find(params[:id]).destroy!
|
|
|
|
render json: {}, status: :ok
|
|
|
|
end
|
2024-07-11 20:08:26 +02:00
|
|
|
end
|