Today I Learned

A Hashrocket project

Ready to join Hashrocket? Find Openings here and apply today.

Rails console sandbox

We can open rails console with a flag to enable --sandbox. That surrounds the whole rails console session into a database transaction that gets rolled back on exit.

bundle exec rails console --sandbox

This way we can play around with data and all the changes will go away after existing the console.

h/t @mattpolito

Looking for help? Hashrocket has been an industry leader in Ruby on Rails since 2008. Rails is a core skill for each developer at Hashrocket, and we'd love to take a look at your project. Contact us and find out how we can help you.