#235 How to hide IDs from page URLs in Ruby on Rails. The smartest approach!

29/03/2025

You definitely want to hide IDs from your app.

It's a very basic security consideration.

There are many Ruby gems that let you hide ids, but neither gem is plug & play:

Some gems require adding a slug attribute to each model.

Some gems require updating your finder methods.

I don't want to decorate my internal resource slugs.

I don't want to care about UUIDs or ULIDs.

I just want to say hide my IDs and it just works.

The best plug & play solution that I found is in Bullettrain source code: http://github.com/bullet-train-co/bullet_train-core

Here's how you can hide ids in your Rails app

Pull Request adding ID obfuscation: https://github.com/yshmarov/moneygun/pull/209

1
Join the conversation
Sign in to access PRO lessons, access private repos, leave comments, create watch lists.
We collect your email address, name and username to create your account. We do not share your email address with anyone else.