Say I have this method:
def create_registration_unless_over_limit
if Registration.count < 50
Registration.create!
else
raise "too many registrations"
end
end
How do I ensure that I never have >= 50 registrations considering that I have more than one rails process running? Theoretically, isn't it possible that two requests come in virtually simultaneously, both run the if statement and see < 50 registrations is true and then both of them create a new registration?