Last active
February 2, 2017 10:14
-
-
Save ivanvanderbyl/6f459bb16431064e5886013f1e29a22f 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
class Booking < ActiveRecord::Model | |
after_create :set_booking_number | |
private | |
def set_booking_number | |
return if booking_number | |
update_column(:booking_number, SecureRandom.hex[0..5].upcase) | |
rescue ActiveRecord::RecordNotUnique | |
retry | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment