简体   繁体   English

Rails服务器命令

[英]Rails Server Command

I am new to Ruby on Rails and am following a tutorial to create a class project. 我是Ruby on Rails的新手,并且正在关注创建类项目的教程。

I can generate a new rails project with 我可以使用生成一个新的Rails项目

   $ rails project

The problem Im having is when I try to start my server, It will generate a project called server: 我遇到的问题是当我尝试启动服务器时,它将生成一个名为server的项目:

   $ rails server

or 要么

   $ rails s

I figured out that I need to install/update rails to 3.0.3 to use this command every time I open terminal. 我发现每次打开终端时都需要将rails安装/更新到3.0.3才能使用此命令。 I find myself having to install gems(bundle, etc) every time I need to work on my project. 我发现自己每次需要在项目上工作时都必须安装gems(捆绑包等)。

Is there anyway to save this terminal session or profile for later use? 无论如何,是否有保存此终端会话或配置文件以供以后使用?

Is it user error? 是用户错误吗?

Im new to Rails and about the same with terminal. 我对Rails还是陌生的,与终端差不多。

Any help would be greatly appreciated. 任何帮助将不胜感激。 I have resorted to leaving my computer and terminal open for about a week... 我不得不将计算机和终端保持打开状态大约一周。

Welcome on board! 欢迎登机! - You'll have fun, I found setting up the environment the most difficult thing. -您会很开心的,我发现设置环境是最困难的事情。 in rails 2 you start the server with ruby script/server . 在rails 2中,您使用ruby script/server启动ruby script/server

to upgrade to rails 3 try gem install rails -v=3.0.4 I put the version but it's not a mandatory option. 升级到Rails 3尝试gem install rails -v=3.0.4我放了版本,但这不是必须的选项。 To uninstall a gem (as rails is) is gem uninstall gemname -v=xxx . 要卸载gem(如rails),请使用gem uninstall gemname -v=xxx - gem list will tell you the version of each gem. - gem list会告诉您每个宝石的版本。 I hope you've got rvm, if not I strongly sugget you to install it, this will allow you not only to use different versions of ruby but also to set different gemsets, therefor one each project, you'll find it useful. 我希望您有rvm,如果没有,我强烈建议您安装它,这不仅使您可以使用不同版本的ruby,而且可以设置不同的gemset,因此每个项目一个,您都会发现它很有用。

Once in rails 3 you can use bundler , have a look at this episode of railscasts , by the way this is a very good site, but you may know it already. 进入Rails 3后,您可以使用bundler ,看一下这一集的railscasts ,顺便说一下,这是一个很好的站点,但是您可能已经知道了。

another edit... I don't know the behavior you're describing, looks like something is wrong with your environment, but I need to know if you have rvm to solve this, if so try rvm list and rvm gemset , With the first you get the list of installed ruby, you can switch between them with rvm 1.9.2 ie and rvm 1.9.2@gemdirname with the gemdir coming from the second list. 另一个编辑...我不知道您正在描述的行为,看起来您的环境有问题,但是我需要知道您是否具有rvm来解决此问题,如果可以,请尝试rvm listrvm gemset ,首先,您将获得已安装红宝石的列表,可以使用rvm 1.9.2 ie和rvm 1.9.2@gemdirname在它们之间进行切换,其中gemdir来自第二个列表。 You should find your configuration in one of those list. 您应该在那些列表之一中找到您的配置。

嗨,如果您使用的是Rails 2.8或更低版本,请使用它来启动服务器

ruby script/server

rails new project用于新的rails项目n rails s用于启动服务器

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

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