wedding-planner/app/controllers/guests_controller.rb
Manuel Bustillo 31d41ea2ea
All checks were successful
Check usage of free licenses / check-licenses (pull_request) Successful in 1m39s
Add copyright notice / copyright_notice (pull_request) Successful in 2m48s
Run unit tests / unit_tests (pull_request) Successful in 3m46s
Remove unused bulk update endpoint
2024-11-17 17:07:29 +01:00

23 lines
637 B
Ruby

# Copyright (C) 2024 Manuel Bustillo
require 'csv'
class GuestsController < ApplicationController
def index
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] } })
end
def create
Guest.create!(params.require(:guest).permit(:name, :group_id, :status))
render json: {}, status: :created
end
def update
Guest.find(params[:id]).update!(params.require(:guest).permit(:name, :status))
render json: {}, status: :ok
end
end