Skip to content

Commit

Permalink
Merge pull request #17 from concertmate/corrections
Browse files Browse the repository at this point in the history
Feat: Corrected some Actions
  • Loading branch information
clydeautin authored Sep 13, 2024
2 parents 0dcd7e6 + a006a09 commit e4b5309
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/controllers/api/v1/attendees_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit e4b5309

Please sign in to comment.