In a project I’m working on in my spare time, I wanted to hide / obfuscate the databases IDs of my ActiveRecord model. I didn’t want the users to find records by simply incrementing a number in the URL.
I ended up writing my own Gem, which manipulates ActiveRecord::Base to hide the actual ID. Rails’s path functions still work as expected. The only thing I had to add to the actual project was the following line:
1 2 3 |
|
I open sourced the project on GitHub (pencil/encrypted_id) and published it on RubyGems.org.