Created
June 7, 2023 06:49
-
-
Save Melrt/3550653e370d468d4fcc8a0a88189191 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/events/registrations_controller.rb | |
class Events::RegistrationsController < ApplicationController | |
def create | |
@event = Event.subscribing.find(params[:event_id]) | |
@event.with_lock do | |
sleep 0.25 # simule un travail plus complexe | |
@ticket = Ticket.create!( | |
validated_at: Time.zone.now, | |
user_name: tickets_params[:user_name], | |
) | |
render json: @ticket, status: :created | |
end | |
end | |
private | |
def tickets_params | |
params.require(:ticket).permit(:user_name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment