wedding-planner/app/controllers/guests_controller.rb
Manuel Bustillo 6f6a6aaabf
All checks were successful
Check usage of free licenses / check-licenses (pull_request) Successful in 4m31s
Add copyright notice / copyright_notice (pull_request) Successful in 18m9s
Run unit tests / unit_tests (pull_request) Successful in 17m2s
Update format of guests API and document endpoints
2024-11-16 02:16:19 +01:00

23 lines
671 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 update
Guest.find(params[:id]).update!(params.require(:guest).permit(:name))
render json: {}, status: :ok
end
def bulk_update
Guests::UpdateUseCase.new(guest_ids: params[:guest_ids], params: params.require(:properties).permit(:status)).call
render json: {}, status: :ok
end
end