Merge pull request 'Define a new public endpoint to get information about an invitation' (#279) from invitations-show-endpoint into main
All checks were successful
Run unit tests / rubocop (push) Has been skipped
Run unit tests / check-licenses (push) Has been skipped
Run unit tests / copyright_notice (push) Has been skipped
Run unit tests / unit_tests (push) Successful in 56s
Run unit tests / build-static-assets (push) Successful in 8m15s

Reviewed-on: #279
This commit is contained in:
bustikiller 2025-06-12 17:32:27 +00:00
commit 9e9ee0c995
2 changed files with 13 additions and 3 deletions

View File

@ -2,9 +2,9 @@
# frozen_string_literal: true
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
class InvitationsController < ApplicationController
skip_before_action :authenticate_user!, only: :show
def index
render json: Invitation.includes(:guests).as_json(
only: :id,
@ -16,6 +16,16 @@ class InvitationsController < ApplicationController
)
end
def show
invitation = Invitation.includes(:guests).find(params[:id])
if invitation
render json: invitation, only: :id, include: { guests: { only: %i[id name] } }, status: :ok
else
render json: { error: 'Invitation not found' }, status: :not_found
end
end
def create
invitation = Invitation.create

View File

@ -42,7 +42,7 @@ Rails.application.routes.draw do
resources :tables_arrangements, only: %i[index show create]
resources :summary, only: :index
resources :invitations, only: %i[index create update destroy]
resources :invitations, only: %i[show index create update destroy]
root to: redirect("/%{slug}")
end