I am following the Ruby on Rails Tutorial: Learn Rails by Example
I am on chapter 2 creating the demo app using scaffolding and have
generated the user scaffold, migrated the database using Rake and then
run the local webserver using 'rails s'
This has all worked great and I now need to generate the next bit of
scaffolding but I don't know how to get back to the command prompt
after using 'rails s' . I know I could launch another terminal session
but is this the only way? Will I be leaving one terminal open running
'rails s' all the time and another to actually work on?
As anyone can tell I am a total newbie to Ruby on Rails but I am keen
to learn and very much appreciate any help with my dumb starter
rails server -d (or --daemon) will start up the server process in the background and return you to your terminal prompt (at least on Linux or OS/X, I haven’t tried it in Windows). But you do get useful output in the server window in terms of error messages and deprecation warnings, so it’s probably worth letting it keep it’s own terminal.
In fact you’ll probably end up finding it useful to have three or four terminal running at once so as to monitor the rails server, log files, your tests running under autotest plus one to actually do stuff in!
you can stop the server with Ctrl+C. If you want to let you application
run all the time in the background just open a new terminal. Another
solution would be to start the server as a deamon 'rails s -d'. But i
would recommend you to let the server output in its own terminal so you
can see if something is going wrong.
don't worry, there's no dummy questions, everyone had to start
On UNIX based systems (MacOS or Linux) just press CTRL+C, and the
server will stop.
Later it can be a good idea to install Thin, because it starts faster,
you do not have to wait when you rebooting server. Then just run "ruby
script/server -thin" (if I remember well).
There's actually a new option, which I think is fantastic:
gem install passenger --pre
This will allow you to run using the server that will most likely power
your Rails application in production, but with the same conveniences as
rails s. You can stop passenger in the same way with (Ctrl-C). Another
nice convenience is that if you need to restart, you can touch
tmp/restart.txt just like you would on the deployment server.
As mentioned by others, it is common and very convenient to run the
server in a separate terminal. I generally have three terminal tabs open
when developing Rails. One for running command line generators and rake,
a second for running autotest (w/ autotest-growl), and a third for
running passenger and monitoring the development log.
Note: The first time you use passenger start it will install a number of
things. Most notably Nginx, which makes developing locally work in a
very similar environment to what production will be.