Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails “没有路线匹配”/索引;。简单的问题?_Ruby On Rails - Fatal编程技术网

Ruby on rails “没有路线匹配”/索引;。简单的问题?

Ruby on rails “没有路线匹配”/索引;。简单的问题?,ruby-on-rails,Ruby On Rails,所有编码领域都是新的,RoR也是新的。我一直在做教程,昨晚遇到了一些问题。我的一个朋友帮我做了一些。我在这里问了几个问题。但这一点让我困惑。我找不到它的问题 页面加载后,会显示需要显示的内容。但当我按下上面的链接时,结果是: Routing Error No route matches "/index" 所以我做了rake路由,我得到了这个 Dennis-Buizerts-MacBook-Pro:gpoff dennisbuizert$ rake routes site_index

所有编码领域都是新的,RoR也是新的。我一直在做教程,昨晚遇到了一些问题。我的一个朋友帮我做了一些。我在这里问了几个问题。但这一点让我困惑。我找不到它的问题

页面加载后,会显示需要显示的内容。但当我按下上面的链接时,结果是:

    Routing Error

No route matches "/index"
所以我做了rake路由,我得到了这个

Dennis-Buizerts-MacBook-Pro:gpoff dennisbuizert$ rake routes
site_index GET /site/index(.:format) {:controller=>"site", :action=>"index"}
site_about GET /site/about(.:format) {:controller=>"site", :action=>"about"}
 site_help GET /site/help(.:format)  {:controller=>"site", :action=>"help"}
      root     /(.:format)           {:controller=>"Site", :action=>"index"}
这是我的路线

root :to => "Site#index"
get "site/index"       
get "site/about"
get "site/help"
我尝试添加
map.connects
match
,但似乎无法解决问题。 我的development.log显示如下:

Started GET "/" for 127.0.0.1 at 2011-08-28 10:05:51 +0200
DEPRECATION WARNING: Disabling sessions for a single controller has been deprecated. Sessions are now lazy loaded. So if you don't access them, consider them off. You can still modify the session cookie options with request.session_options. (called from <class:ApplicationController> at /Users/dennisbuizert/Sites/gpoff/app/controllers/application_controller.rb:3)
  Processing by SiteController#index as HTML
Rendered site/index.html.erb within layouts/application (1.6ms)
Completed 200 OK in 5ms (Views: 4.3ms | ActiveRecord: 0.0ms)


Started GET "/index" for 127.0.0.1 at 2011-08-28 10:05:52 +0200

ActionController::RoutingError (No route matches "/index"):


Rendered /Users/dennisbuizert/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.8ms)
于2011-08-28 10:05:51+0200开始获取127.0.0.1的“/”
不推荐使用警告:已不推荐为单个控制器禁用会话。会话现在是延迟加载的。所以,如果你不访问它们,就考虑它们。您仍然可以使用request.session\u选项修改会话cookie选项。(从at/Users/dennisbuizert/Sites/gpoff/app/controllers/application_controller.rb:3调用)
由SiteController处理#索引为HTML
布局/应用程序中呈现的站点/index.html.erb(1.6ms)
在5毫秒内完成200 OK(视图:4.3毫秒|活动记录:0.0毫秒)
2011年8月28日10:05:52+0200开始获取127.0.0.1的“索引”
ActionController::RoutingError(没有与之匹配的路由“/索引”):
rescues/layout中的Rendered/Users/dennisbuizert/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/action\u dispatch/middleware/templates/rescues/routing\u error.erb(0.8ms)
试试看

而不是

get "site/index"  

如果没有人回复,你可以试试。有一大群RoR助手在那里闲逛。谢谢,我会记住这一点。这个指向
/index
的链接是如何创建的?因为根不应该是
/index
,而应该是普通的
/
。谢谢。这把它修好了。这是工作吗?或者稍后我会发现这是一个很好的解决方案吗?@dbuizert,Imm,这可能是一个解决办法,但是如果你不改变路线,你需要改变到
/site/index
/code>的链接,而不是视图或布局文件中的
/index
。事实上,坦率地说,你根本不应该到达
/index
。只要
/
就足够了。此解决方案确实可以确保您可以键入
/index
,但通常不需要这样做。
get "site/index"