ruby-on-rails - 没有路由匹配 "/index"。简单的问题?

标签 ruby-on-rails

所有编码世界的新手和 RoR 的新手。我一直在做一个教程,昨晚遇到了一些问题。我的一个 friend 帮助了其中的一些。我在这里问了几个。然而,这一点让我感到困惑。我找不到它的问题。

页面加载,它显示需要显示的内容。但是当我点击那里的链接时,结果如下:

    Routing Error

No route matches "/index"

所以我做了 rake routes我得到了这个
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"}

这是在我的 routes.rb
root :to => "Site#index"
get "site/index"       
get "site/about"
get "site/help"

我尝试添加 map.connectsmatch但这似乎并没有解决它。
我的 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)

最佳答案

尝试

get 'index' => "site#index"

代替
get "site/index"  

关于ruby-on-rails - 没有路由匹配 "/index"。简单的问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7219778/

相关文章:

ruby-on-rails - Rails - 用户和管理员的 CRUD,有多少个 Controller ?

ruby-on-rails - OmniAuth Facebook 添加到 Devise

javascript - Rails 3. 链接到 javascript 文件中的图像在生产中不起作用

ruby-on-rails - 如何在 Cloud66 Rails 配置上运行 rake 命令?

ruby-on-rails - rails : How do I reset models and migrations?

ruby-on-rails - Ruby on Rails 4 中的本地语言和 SEO 友好 url

ruby-on-rails - delayed_job 命名队列的单独日志

ruby-on-rails - Redis 如何与 Rails 和 Sidekiq 一起工作

ruby-on-rails - 为什么 DateTime.now.in_time_zone(-4) 和 DateTime.now.in_time_zone(-3) 的输出相同

ruby-on-rails - 使用 Chartkick 添加注释