【发布时间】:2012-03-24 06:22:02
【问题描述】:
我是一个菜鸟,正在学习 Steve Holzner 的《Beginning Ruby on Rails》一书。他告诉我制作一个名为 hello_controller 的控制器,编辑控制器使其显示
class HelloController < ApplicationController
def there
end
end
然后他告诉我创建一个名为 there.rhtml 的文档,其中包含一些简单的 HTML,并将其放在 views/hello 目录中。 然后,我启动 Rails 服务器,导航到 localhost:3000/hello/there,HTML 的结果应该出现在页面上, 我明白了:
Routing Error
No route matches [GET] "/hello/there"
Try running rake routes for more information on available routes.
【问题讨论】:
-
'rake routes' 的结果是?
-
另外,您可能需要检查您正在阅读的书的日期——如果您使用
.rhtml来查看您的观点,那么您使用的是旧版 Rails(您知道,也许两年前,甚至更久!!:-)。从为 Rails 3.1 或更高版本编写的书开始——发生了很大的变化。 -
在另一篇关于 SO 的帖子中对路线有一些很好的解释。 [stackoverflow.com/questions/5733101/…
标签: ruby-on-rails ruby controller