Return guest that has just been created
All checks were successful
Run unit tests / copyright_notice (pull_request) Successful in 40s
Run unit tests / rubocop (pull_request) Successful in 1m2s
Run unit tests / unit_tests (pull_request) Successful in 1m39s
Run unit tests / check-licenses (pull_request) Successful in 34s
Run unit tests / build-static-assets (pull_request) Successful in 21m2s
All checks were successful
Run unit tests / copyright_notice (pull_request) Successful in 40s
Run unit tests / rubocop (pull_request) Successful in 1m2s
Run unit tests / unit_tests (pull_request) Successful in 1m39s
Run unit tests / check-licenses (pull_request) Successful in 34s
Run unit tests / build-static-assets (pull_request) Successful in 21m2s
This commit is contained in:
parent
9461fa5255
commit
4a107d6728
@ -5,21 +5,22 @@
|
||||
require 'csv'
|
||||
|
||||
class GuestsController < ApplicationController
|
||||
GUEST_PARAMS = { only: %i[id name status], include: { group: { only: %i[id name] } } }.freeze
|
||||
def index
|
||||
render json: Guest.includes(:group)
|
||||
.left_joins(:group)
|
||||
.order('groups.name' => :asc, name: :asc)
|
||||
.as_json(only: %i[id name status], include: { group: { only: %i[id name] } })
|
||||
.as_json(GUEST_PARAMS)
|
||||
end
|
||||
|
||||
def create
|
||||
Guest.create!(guest_params)
|
||||
render json: {}, status: :created
|
||||
guest = Guest.create!(guest_params)
|
||||
render json: guest.as_json(GUEST_PARAMS), status: :created
|
||||
end
|
||||
|
||||
def update
|
||||
Guest.find(params[:id]).update!(guest_params)
|
||||
render json: {}, status: :ok
|
||||
guest = Guest.find(params[:id]).update!(guest_params)
|
||||
render json: guest.as_json(GUEST_PARAMS), status: :ok
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
@ -5,16 +5,12 @@
|
||||
class SerializableGuest < JSONAPI::Serializable::Resource
|
||||
type 'guest'
|
||||
|
||||
attributes :id, :group_id, :status
|
||||
attributes :id, :status
|
||||
|
||||
attribute :name do
|
||||
@object.name
|
||||
end
|
||||
|
||||
attribute :group_name do
|
||||
@object.group.name
|
||||
end
|
||||
|
||||
attribute :status do
|
||||
@object.status.capitalize
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user