Is there a way to run rails server
in sandboxed mode?
I would want all the changes made on the rails app to be rolled back after the server is stopped.
For example, doing the command rails console --sandbox
.
One of the things rails server does is that it loads all the dependencies/gems required by your Rails app, or at least sets them up to be auto-loaded later when they are needed. This is sometimes called "booting" or loading the "Rails environment".
Go to your browser and open http://localhost:3000, you will see a basic Rails app running. You can also use the alias "s" to start the server: bin/rails s . The server can be run on a different port using the -p option. The default development environment can be changed using -e .
The console command lets you interact with your Rails application from the command line. On the underside, bin/rails console uses IRB, so if you've ever used it, you'll be right at home. This is useful for testing out quick ideas with code and changing data server-side without touching the website.
There's no build in way to do this. You can start rails console in sandbox mode (rails c -s), but not server.
But... If the changes you want to be rolled back, are only changes in your data, you can just write your seeds data and populate database with them every time you run server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With