Ruby/Rails Engineer
I’m a freelance Ruby/Rails engineer, who loves working with great people to make interesting things. If you’re creating something interesting, get in touch! You can probably hire me.
As my son once said, “Let’s go build all the things!”
Userescue ActiveRecord::RecordNotUnique
withretry
to handle collisions when applicable.
If you need a random, unique token, useSecureRandom.uuid
(orSecureRandom.urlsafe_base64
for something shorter).
Use :if => :field_changed?
on uniqueness validations to skip unnecessary checks on every save.
Regex doesn't play nicely with unicode in Ruby 1.8, so watch your input data! Specifically, '\W' (non-word character) only matches ascii characters.
You may need to reinstall the pg gem after upgrading postgres.