简体   繁体   English

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

[英]Starting script/console for Ruby on Rails with Windows

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 / console”,我得到了这个:

'script' is not recognized as an internal or external command, operable program or batch file. “脚本”不被识别为内部或外部命令,可操作程序或批处理文件。

And when I type "ruby script/console" I get this: 当我输入“ruby script / console”时,我得到了这个:

Ruby: No such file or directory -- script/console (LoadError) Ruby:没有这样的文件或目录 - 脚本/控制台(LoadError)

Any ideas? 有任何想法吗? Should I be running these commands from the root? 我应该从根运行这些命令吗? Thanks. 谢谢。

The usage ruby script/console is present in Rails 2.3.x versions and older. 使用ruby script/console存在于Rails 2.3.x及更早版本中。 I believe you installed Rails 3.x which deprecated that command. 我相信您安装了Rails 3.x,该命令弃用了该命令。

You need to use now rails console or rails c (short version) from the application directory. 您需要从应用程序目录中使用now rails consolerails c (简短版本)。

Better pay a visit to the Rails guides for all the other changes. 更好地访问Rails指南以了解所有其他更改。

In Windows you need to use backslash (\\) instead of the regular slash (/). 在Windows中,您需要使用反斜杠(\\)而不是常规斜杠(/)。

script\\console should work for you, provided you use Rails 2.x. 如果您使用Rails 2.x, script\\console应该适合您。 On Rails 3 use rails console as mentioned by other coleagues. 在Rails 3上使用rails console如其他同事所述。

Is ruby installed? 是否安装了ruby? Is it in your PATH? 它在你的PATH中吗?

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". 如果已安装,则(在Windows 7上),转到Start Orb,键入“path”并单击“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. 在“变量值”列表的末尾添加另一个分号和ruby.exe的路径。

EG: ";C:\\Ruby\\bin" EG:“; C:\\ Ruby \\ bin”

DO NOT delete anything else from that field. 请勿从该字段中删除任何其他内容。

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

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