Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there is a way to do something like rails server --sandbox?

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.

like image 913
Américo Duarte Avatar asked Aug 01 '13 23:08

Américo Duarte


People also ask

What happens when we run rails server?

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".

How do I run a Rails server on a different port?

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 .

What does Rails console do?

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.


1 Answers

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.

like image 136
Marek Takac Avatar answered Sep 17 '22 19:09

Marek Takac