0

I am new to Rails and working my way through RonR3 Tutorial. Everything has worked perfectly except by page 59

$ rails generate scaffold Micropost content: String user_id:integer. 

When I try to run rails s or rails server my terminal application never seems to end. When I ctrl-c to shut down the server after 10+ hours the site can not be found on localHost. Any help would be much appreciated.

Everything seems to stall out around:

Started GET "/assets/users.js?body=1" for 127.0.0.1 at 2012-09-20 13:33:54 -0400
Served asset /users.js - 304 Not Modified (0ms)


Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2012-09-20 13:33:54 -0400
Served asset /jquery_ujs.js - 304 Not Modified (0ms)

After this the terminal just sits there doing nothing...

reto
  • 16,189
  • 7
  • 53
  • 67
  • 1
    You want the server to keep running? but close the terminal ? – guru Sep 20 '12 at 21:12
  • So you've tried to access http://localhost:3000 via a browser and it just sits there? The terminal isn't supposed to do anything in the foreground except display log info once it has been started. – PinnyM Sep 20 '12 at 21:12
  • First, thank you for the quick reply. Right now I am stuck, in that the book has me calling the Rails S which starts just fine however, it never gets back to giving me access to a command prompt. Last night I left the computer running thinking it might just be a slow process. But when I woke up this morning the same issue no command line in terminal. So, I cntl-c to have the server stop. At that point localhost could not be viewed from the browser. When I start rails s again immediately localhost works.... but can not go any further without terminal. Thanks again for any help in advance. – user1686859 Sep 20 '12 at 22:40
  • You may want to refer to it as "Rails" or "RoR". – Dave Newton Sep 21 '12 at 00:31
  • thats normal. rails server (or short rails s) starts the server and keeps it running. In this terminal you'll see all the output of your rails server, for example all exceptions/errors. Just use one terminal to run the server, and others for everything else. – reto Sep 21 '12 at 15:54
  • Thank you everyone for responding: made it past page 59 now stuck on page 101... thanks dave- noted – user1686859 Oct 14 '12 at 22:17

1 Answers1

1

With programs run from the terminal, they will run there unless they stop or have a daemon option. When you press ctrl-c, the rails webbrick server stops, so of course localhost won't show anything.

When the server is sitting there, it's waiting for a user to visit the site. It won't render views, for example, unless there's a request to render views.

If you want to run the webserver while still using the same terminal window, you need to run rails s as a daemon (background process). Instead, run the command as rails s -d which will "detach" the server process.

On a side-note, why not open multiple terminal windows, if your operating system has a GUI/Window Manager. I normally keep three terminal windows open to run the server, make git commits, check rake routes, etc.

Related Question: Running Webrick server in background?

Community
  • 1
  • 1
GorrillaMcD
  • 1,884
  • 1
  • 14
  • 22
  • Gorrilla: Thank you- I will try this immediately. Unfortunately, I am not only new to programming, and RonR but also Mac :) When you made your comment it made perfect sense- again thanks for taking the time to reply. – user1686859 Sep 20 '12 at 23:58
  • No problem. I started with RoR only 7 months ago, so I understand. This site is a great help since you'll find sometimes you don't even know the right terminology to search google with for your problem. If you haven't already, check out http://railscasts.com/ to and get the pro for $9/month. It's well worth it. Also, you can mark the question as answered. – GorrillaMcD Sep 21 '12 at 03:56