Img source: careerfoundry.com

There can be cases when you need to test something with the actual data, in a production environment, but you do not want to risk anything. You do not want to even think about the possibility for a data loss of the project that you are working it. Luckily, there is a really beneficial feature that is not that much known from Rails developers is a quick tool that you can use to test out some code without changing any data in your real database.

You can invoke it like the following:

rails console --sandbox

Here is an example:

As you can see, it will rollback all the changes that may have been committed during the session. This means that you can test database queries guilt-free with actual data, without having to bother about preparing actual data.

This was just a quick tip, and I hope you it improves your productivity.