Allow updating the status of guests from unauthenticated sessions #280
@ -22,12 +22,6 @@ class GuestsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if user_signed_in?
|
|
||||||
permitted_params = guest_params
|
|
||||||
else
|
|
||||||
permitted_params = params.expect(guest: %i[status])
|
|
||||||
end
|
|
||||||
|
|
||||||
guest = Guest.find(params[:id]).update!(guest_params)
|
guest = Guest.find(params[:id]).update!(guest_params)
|
||||||
render json: guest.as_json(GUEST_PARAMS), status: :ok
|
render json: guest.as_json(GUEST_PARAMS), status: :ok
|
||||||
end
|
end
|
||||||
@ -40,6 +34,6 @@ class GuestsController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def guest_params
|
def guest_params
|
||||||
params.expect(guest: %i[name group_id status])
|
user_signed_in? ? params.expect(guest: %i[name group_id status]) : params.expect(guest: %i[status])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user