使用 Windows 启动 Ruby on Rails 的脚本/控制台

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5412832/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:29:27  来源:igfitidea点击:

Starting script/console for Ruby on Rails with Windows

ruby-on-railsrubywindows

提问by Colin

I'm having trouble starting script/console.

我在启动脚本/控制台时遇到问题。

I've tried cd'ing into the project root ("C:\MyProject") then typing "script/console" and I get this:

我试过cd进入项目根目录(“C:\MyProject”)然后输入“脚本/控制台”,我得到了这个:

'script' is not recognized as an internal or external command, operable program or batch file.

'script' 不是内部或外部命令,也不是可运行的程序或批处理文件。

And when I type "ruby script/console" I get this:

当我输入“ruby 脚本/控制台”时,我得到了这个:

Ruby: No such file or directory -- script/console (LoadError)

Ruby:没有这样的文件或目录——脚本/控制台(LoadError)

Any ideas? Should I be running these commands from the root? Thanks.

有任何想法吗?我应该从根运行这些命令吗?谢谢。

回答by Luis Lavena

The usage ruby script/consoleis present in Rails 2.3.x versions and older. I believe you installed Rails 3.x which deprecated that command.

该用法ruby script/console存在于 Rails 2.3.x 版本及更早版本中。我相信你安装了 Rails 3.x,它弃用了该命令。

You need to use now rails consoleor rails c(short version) from the application directory.

您需要从应用程序目录中使用 nowrails consolerails c(简短版本)。

Better pay a visit to the Rails guidesfor all the other changes.

最好访问Rails 指南以了解所有其他更改。

回答by Jan Kori?ák

In Windows you need to use backslash (\) instead of the regular slash (/).

在 Windows 中,您需要使用反斜杠 (\) 而不是常规斜杠 (/)。

script\consoleshould work for you, provided you use Rails 2.x. On Rails 3 use rails consoleas mentioned by other coleagues.

script\console如果您使用 Rails 2.x,应该对您有用。rails console其他同事提到的在 Rails 3 上使用。

回答by Preacher

Is ruby installed? Is it in your PATH?

ruby 安装了吗?它在你的路径中吗?

http://www.ruby-lang.org/en/downloads/

http://www.ruby-lang.org/en/downloads/

When it installs, look for the checkbox to add ruby to your path.

安装时,查找复选框以将 ruby​​ 添加到您的路径。

If it's already installed, then (on Windows 7), go to the Start Orb, type "path" and click on "Edit the system environment variables". Click on "Environment Variables". In the bottom list scroll down to "Path". Select "Path" and click "Edit". At the end of the "variable value" list put another semi-colon and the path to your ruby.exe.

如果它已经安装,那么(在 Windows 7 上),转到 Start Orb,键入“path”并单击“Edit the system environment variables”。单击“环境变量”。在底部列表中向下滚动到“路径”。选择“路径”,然后单击“编辑”。在“变量值”列表的末尾放置另一个分号和 ruby​​.exe 的路径。

EG: ";C:\Ruby\bin"

EG: ";C:\Ruby\bin"

DO NOT delete anything else from that field.

不要从该字段中删除任何其他内容。