-2

所以,

几个小时前支付了 PDF,仔细按照说明进行操作,但在启动 first_app 后,我在 localhost:3000 中看到了这个:

Routing Error

No route matches [GET] "/"

没有接触任何代码,只是在执行“rails new first_app”后启动了服务器。

从命令行:

552 ~/Downloads/rails_projects/first_app>=> Booting WEBrick
=> Rails 3.1.0.rc6 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Sprockets::Environment#static_root is deprecated
[2011-08-20 16:44:40] INFO  WEBrick 1.3.1
[2011-08-20 16:44:40] INFO  ruby 1.9.2 (2011-07-09) [x86_64-darwin10.8.0]
[2011-08-20 16:44:40] INFO  WEBrick::HTTPServer#start: pid=97719 port=3000

552 ~/Downloads/rails_projects/first_app>cache: [GET /] miss

Started GET "/" for 127.0.0.1 at 2011-08-20 16:45:06 -0400

ActionController::RoutingError (No route matches [GET] "/"):

Rendered /Users/briano/.rvm/gems/ruby-1.9.2-p290@rails3.1/gems/actionpack-3.1.0.rc6
/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within 
rescues/layout (7.3ms)

使用 rails 3.1 和 ruby​​ 1.9.2:

554 ~/Downloads/rails_projects/first_app>rails -v
Rails 3.1.0.rc6
555 ~/Downloads/rails_projects/first_app>ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]

使用 rvm,创建了一个特殊的 gemset,等等。有什么想法吗?

4

4 回答 4

1

服务器正在尝试使用缓存机制(因为它处于生产模式)。

尝试在开发中运行它。

这个问题有很多关于如何在生产中运行你的应用程序的答案(简单地说,用开发替换他们的解决方案)。

于 2011-11-27T23:36:06.623 回答
0

即使我面临同样的问题。可能的问题可能是您在不同的应用程序目录上运行 rails 服务器。尝试从与您的应用程序相同的路径运行您的 Rails 服务器。

于 2013-04-04T01:13:07.893 回答
0

您是否尝试过创建一个新应用并再次运行 rails server 命令?一定要回复我的答案..

于 2011-08-25T12:21:17.837 回答
0

我认为这是来自演示应用程序。第一个应用程序没有控制器,所以有些东西坏了,但你会在第二个应用程序中再次看到这一点,demo_app在第一个应用程序中,尝试取消注释/# root :to => 'welcome#index'并确保index.html文件是公开的。

当您在demo_app: You have no route for main app或应用程序的“根”中看到这一点时。
如果您将地址更改为http://localhost:3000/users, index 操作,即
用户的 html Get 将显示您的所有用户,此时为无。
要解决此问题,您需要添加到主 url( http://localhost:3000 ) 的路由。
如果您键入"rake routes",您会看到有用户路由但没有 root 路由。

打开config/routes.rb底部附近的文件,将行:更改 /# root :to => 'welcome#index' 为:root :to => 'users#index'

users#index与 rake 路由的第一条路由相同。

{:action=>"index", :controller=>"users"}

您已更改默认操作以转到用户控制器和索引操作。Rake 路由现在显示根条目。

于 2011-11-29T07:01:08.917 回答