简体   繁体   English

Rails-启动服务器后没有命令提示符?

[英]Rails - no command prompt after starting server?

total n00b question here but I can't seem to find the answer searching around here or the web. 这里总共有n00b个问题,但我似乎找不到在这里或网上搜索的答案。

I have Ruby v1.8.7 (2009-06-12 patchlevel 174) and Rails v.2.3.5 installed on my Mac (10.6.8). 我在Mac(10.6.8)上安装了Ruby v1.8.7(2009-06-12补丁程序级别174)和Rails v.2.3.5。 I have no problem generating a Rails directory and starting the Ruby server, but what happens is that once the server is started I have no prompt and no code I type seems to execute. 我生成Rails目录并启动Ruby服务器没有问题,但是发生的事情是,一旦服务器启动,我将没有提示,而且输入的代码似乎也不会执行。

to be specific - here is the terminal code from a session: 具体来说-这是会话中的终端代码:

bvb:new bennettvonbennett$ ruby script/server
=> Booting Mongrel
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

after this point there is no prompt and no command I type seems to produce a result. 在这一点之后,没有提示,并且我键入的命令似乎都不会产生结果。

what am I doing wrong? 我究竟做错了什么?

This is the correct behavior. 这是正确的行为。 You're not doing anything wrong. 你没做错什么

The server runs in the foreground so that you can see the log output on every page load without having to open a specific log file. 服务器在前台运行,因此您无需打开特定的日志文件即可在每次页面加载时看到日志输出。 It's very helpful for debugging and staying aware of what the code you write does to the application and the database. 这对于调试和保持您编写的代码对应用程序和数据库的作用非常有用。

To return to a normal command prompt, you can send an end-of-text character (usually ctrl-c) to stop the server. 要返回正常的命令提示符,您可以发送文本结尾字符(通常为ctrl-c)以停止服务器。 Most of us Rails-folk work with multiple terminal windows open - server running in one, and others for other functions, such as the rails console, started with 我们大多数人都在打开多个终端窗口的情况下使用Rails-folk-服务器运行在一个窗口中,而其他运行于其他功能的窗口(例如Rails控制台)则以

ruby script/console

which will let you experiment with other Rails controller functions, much like irb for standard Ruby. 它可以让您尝试其他Rails控制器功能,就像标准Ruby的irb一样。

With ruby script/server you launch the webserver. 使用ruby script/server启动Web服务器。 Run ruby script/console if you want to execute commands against your current Rails application. 如果要对当前的Rails应用程序执行命令,请运行ruby script/console

You're loooking for: 您正在寻找:

script/console

If you want to play with your project in a console. 如果要在控制台中玩项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM