Ruby on rails “没有路线匹配”/&引用;?

Ruby on rails “没有路线匹配”/&引用;?,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,我知道这似乎是一个非常简单的错误,但它来自一个复杂的过程 我正在尝试将一个旧的rails 2应用程序升级到rails 3。在我的routes.rb文件中,我有 root :to => "home#index" 我还有一个文件'app/controllers/home\u controller.rb'和一个'app/views/home/index.html.erb',所以我根本不知道是什么导致了这个错误。升级到rails 3并不容易 (在home_controller.rb中,我有def

我知道这似乎是一个非常简单的错误,但它来自一个复杂的过程

我正在尝试将一个旧的rails 2应用程序升级到rails 3。在我的routes.rb文件中,我有

root :to => "home#index"
我还有一个文件'app/controllers/home\u controller.rb'和一个'app/views/home/index.html.erb',所以我根本不知道是什么导致了这个错误。升级到rails 3并不容易

(在home_controller.rb中,我有
def索引
结束

有什么建议吗

***更新-完整路由文件***

 SpecimenTracker::Application.routes do
  map.resources :users

  map.resource :session

  # The priority is based upon order of creation: first created -> highest priority.

  # Sample of regular route:
  #   map.connect 'products/:id', :controller => 'catalog', :action => 'view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   map.resources :products

  # Sample resource route with options:
  #   map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }

  # Sample resource route with sub-resources:
  #   map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller

  # Sample resource route with more complex sub-resources
  #   map.resources :products do |products|
  #     products.resources :comments
  #     products.resources :sales, :collection => { :recent => :get }
  #   end

  # Sample resource route within a namespace:
  #   map.namespace :admin do |admin|
  #     # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
  #     admin.resources :products
  #   end

  # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
get "home/index"
root :to => "home#index"
  # See how all your routes lay out with "rake routes"

  # Install the default routes as the lowest priority.
  # Note: These default routes make all actions in every controller accessible via GET requests. You should
  # consider removing the them or commenting them out if you're using named routes and resources.
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
end

为了确定,您是否尝试重新启动Webrick(或您正在使用的任何其他服务器)。虽然这很简单,但最终总会让你绊倒:)

如果这不是问题所在,请发布日志文件(log/development.log)


编辑:刚刚看到你文章的更新。尝试逐行删除routes文件中的其他(未注释的)行,直到问题得到解决

为了确保,您是否尝试重新启动Webrick(或您正在使用的任何其他服务器)。虽然这很简单,但最终总会让你绊倒:)

如果这不是问题所在,请发布日志文件(log/development.log)


编辑:刚刚看到你文章的更新。尝试逐行删除routes文件中的其他(未注释的)行,直到问题得到解决

删除两个map.connect语句。在rails3中不需要它们

顶部的资源应该是:

  resources :users
  resources :sessions

删除两个map.connect语句。在rails3中不需要它们

顶部的资源应该是:

  resources :users
  resources :sessions
“map.connect”、“map.resources”是旧语法

My Rails 3 routes.rb以

ApplicationName::Application.routes.draw do
从外到内的Rails路由:“map.connect”、“map.resources”是旧语法

My Rails 3 routes.rb以

ApplicationName::Application.routes.draw do
从外到内的轨道布线:

尝试:

root :to => 'home#index'
注意单引号<代码>#在Ruby中的双引号字符串中具有特殊意义。

试试:

root :to => 'home#index'

注意单引号
#
在Ruby中的双引号字符串中具有特殊意义。

rake routes的输出是什么rake routes的输出是什么是的,尝试逐行删除,但仍然没有任何结果。。我的日志包含以下内容:
Started GET”/“for 192.168.1.114于2011年8月18日星期四17:17:10+0000 ActionController::RoutingError(无路由匹配):
(加上一系列其他错误,但这些都是警告,因为一些rails 2的东西不适用于rails 3,对查找项目路线没有影响。)Yeah尝试逐行删除,但仍然没有任何结果。我的日志包含以下内容:
Started GET“/”for 192.168.1.114,时间为2011年8月18日星期四17:17:10+0000 ActionController::RoutingError(无路由匹配“/):
(加上一系列其他错误,但这些都是警告,因为一些rails 2的东西不适用于rails 3,对找到项目的路由没有影响}捕获良好但仍然没有解决问题,将消息保存在浏览器中并记录:
ActionController::RoutingError(无路由匹配“/):
捕捉得很好,但仍然没有解决问题,将消息保存在浏览器中并记录:
ActionController::RoutingError(没有路由匹配”/“):
太好了!现在开始下一个问题(附:我忘记了
.draw
,我正在做
映射。参考资料
)太好了!现在开始下一个问题(另外,我忘记了
.draw
,我正在做
map.resources