运行多个 Rails Server 实例 [英] Running multiple instances of Rails Server

查看:52
本文介绍了运行多个 Rails Server 实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Rails 的新手,所以如果这很明显,请原谅我.

I am new to Rails, so please forgive me if this is obvious.

我正在进行大量试验、创建应用程序、测试功能等.它让我的第一个脚手架应用程序运行良好,但我想创建第二个应用程序来测试不同的功能.

I am doing a lot of experimenting, creating to applications, testing features, etc. It got my first scaffolded app running great, but I wanted to create a second app to test a different feature.

我在我的计算机上备份了一个文件夹级别,运行 $ rails new taskmaster(一个测试待办事项列表应用程序).我运行了 Task 模型的脚手架,通过 $ rails server 启动了服务器,并尝试加载 http://localhost:3000.

I backed up a folder level on my computer, ran $ rails new taskmaster (a test to-do list app). I ran the scaffolding for the Task model, fired up the server via $ rails server, and attempted to load http://localhost:3000.

但是我遇到路由错误,说它找不到 "members" 路由.但是 members 来自我的第一个 Rails 应用!我认为通过在 taskmaster 目录中触发 $ rails server,它将为该应用程序启动服务器.

But I got a routing error, saying it couldn't find the "members" route. But members was from my first Rails app! I thought by firing off $ rails server in the taskmaster directory, it would startup the server for that application.

如何告诉 Rails 服务器提供哪个应用程序?

How do I tell the Rails server which application to serve up?

更新

我刚刚发现,如果我:

  1. 在我创建 Member 脚手架之前,回滚到 第一个 Rails 应用程序的全新安装
  2. 通过应用根目录中的$ rails server启动rails服务器
  3. 检查http://localhost:3000
  1. Roll back to the fresh install of the first Rails app, before I created the Member scaffold
  2. Fire up the rails server via $ rails server in the application's root directory
  3. Check http://localhost:3000

它仍然尝试走 members 路线,该路线不再存在,因为我通过 git 回滚了.

It still attempts to go for the members route, the one that no longer exists because I rolled back via git.

我猜这意味着我的 /usr/local/ 区域中的某些东西,与我的 Ruby 和 Rails 初始安装有关,正在维护此信息(我的应用程序设置在我的 Documents 文件夹中家庭目录).

I'm guessing this means something in my /usr/local/ area, relating to my Ruby and Rails initial installs, is mainatining this info (my apps are setup in my Documents folder in my home dir).

我认为 Rails 应用程序本质上是目录中的自包含应用程序 - 您只需要安装一个有效的 Ruby 即可让它们运行.Rails 服务器是否位于每个应用程序目录中,还是某个包含所有应用程序的总体 Rails 服务器?

I thought that Rails apps were essentially self contained apps inside the directory - you just needed a working Ruby install to get them going. Does the Rails server sit inside each app directory, or is the some overarching Rails server that accommodates all apps?

推荐答案

感谢您的所有帮助 - 事实证明这是一个相当奇怪的事件.不知何故,我的整个项目文件夹都被复制到垃圾箱中.当我启动服务器时,我正在垃圾箱副本中启动服务器实例,而我回滚和编辑的副本则留在同一个地方.不知道这是怎么发生的(也许它与 git,我刚刚学习的另一个工具有关).无论如何,感谢所有的帮助,对不起,事情太简单了!

Thanks for all your help - turns out it was a rather strange occurrence. Somehow, my entire project folder got copied into the Trash. When I started the server, I was starting the server instance in the Trash copy, while the copy I rolled back and edited stay in the same place. Not sure how that happened (perhaps it relates to git, another tool I am just learning). In any case, thanks for all the help, sorry it was something so simple!

这篇关于运行多个 Rails Server 实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆