0

我无法让http://guides.rubyonrails.org/getting_started.html教程工作。创建 rails 项目并运行 rails server 以查看“欢迎加入”页面后,我在浏览器中收到“页面不存在”错误。我尝试了资产:预编译,但是没有用。这曾经可以正常工作,但现在不行了。Rails 版本 3.2.13

这是 production.log 中我认为可能相关的部分:

ActionController::RoutingError (No route matches [GET] "/"):
  actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
  railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
4

3 回答 3

6

确保在 config/routes.rb 文件中设置了路由的根目录。

试试root to: "welcome#index"

于 2013-07-01T01:48:02.467 回答
0

您需要将根路由添加到config/routes.rb文件中,例如:

root to: 'things#index'

在这个例子中,你必须有app/controllers/things_controller.rb

class ThingsController < ApplicationController
  def index
  end

和 view app/views/things.html.erb,可能是一个空文件。

于 2013-07-01T01:47:29.380 回答
0

One thing they do not tell you in the tutorial is in order to see a new scaffold or view etc you will need to delete the default rails view(index.html) inside of the public folder. After you have done so make sure yours routes are correct and most importantly restart your server after doing changing route file.

于 2013-07-01T01:50:58.497 回答