From a006a0908d0df909ab72fef5ae93668456618c2d Mon Sep 17 00:00:00 2001 From: Garrett Bowman Date: Fri, 13 Sep 2024 16:03:46 -0500 Subject: [PATCH] Feat: Corrected some Actions --- app/controllers/api/v1/attendees_controller.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/v1/attendees_controller.rb b/app/controllers/api/v1/attendees_controller.rb index 7e5558e..867f766 100644 --- a/app/controllers/api/v1/attendees_controller.rb +++ b/app/controllers/api/v1/attendees_controller.rb @@ -1,7 +1,7 @@ class Api::V1::AttendeesController < ApplicationController def create - attendee = Attendee.new(attendee_params) - + event = Event.find(attendee_params[:event_id]) + attendee = event.attendees.new(attendee_params) if attendee.save render json: AttendeeSerializer.new(attendee), status: :created else @@ -10,11 +10,10 @@ def create end def destroy - attendee = Attendee.find(params[:id]) - # require 'pry'; binding.pry + attendee = Attendee.find_by(user_id: params[:id]) if attendee attendee.destroy - render json: { message: 'Attendee removed successfully' }, status: :no_content + render json: { message: 'Attendee removed successfully' }, status: :ok else render json: { errors: 'Attendee not found' }, status: :not_found end