-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gem not working with Rails 5 #51
Comments
If people are looking for a Rails 5 compatible solution in the mean time, I simply did:
Or if you are using PostgreSQL:
|
@gregblass will that check for duplicates also? |
@varun-raj I would think that PostgreSQL would probably handle that automatically, but I actually use MYSQL because it does the job and I'm too lazy to switch over so I'm not sure. That ruby method would not check for duplicates, however a random UUID has 122 random bits. Assuming perfect randomness, you can expect the first collision at around 2^61 generated UUIDs (that's the square root of 2^122). If everyone on this earth were to generate a UUID per second, that's 10,000,000,000_365_24_60_60 = 315360000000000000 UUIDs per year, which is quite close to 2^58. That is, after a few years you would get the first collisions. Unless your application gets anywhere near those numbers, you can be pretty sure that you won't get a collision if your random generator is of decent quality. You could do something like this:
This of course adds a database call. For me, I'm using it to generate random ID's for payment transactions so users can't see how many transactions I've done. By the time I've got anywhere near that many transactions, I'd be the richest person on earth. |
Hi @gregblass and @varun-raj , since this repository is kind deprecated, I created a gem to do that: https://github.com/wbotelhos/idy I tested this scenario and it works. I would love your feedback. |
I just propose a pull request with rails 5 compatibility and test |
When upgrading to Rails 5, bundler works for all my other gems - but when I add obfuscate_id, this is the error I get:
The text was updated successfully, but these errors were encountered: