2011-08-18 127 views
1

我知道这似乎是一个非常简单的错误,但它来自一个复杂的过程。没有路线匹配“/”?

我试着去升级老梁2应用轨道3.在我的routes.rb文件,我有

root :to => "home#index" 

而且我也有一个文件“应用程序/控制器/ home_controller.rb”和'app/views/home/index.html.erb',所以我根本没有得到什么可能导致这个错误。升级到rails 3并非易事。

(在home_controller.rb,我有def index end

有什么建议?

**更新 - FULL routes文件* *

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 
+1

'rake routes'的输出是什么 – austinbv

+0

@austinbv更新以上 –

回答

5

的 “map.connect”, “map.resources” 是旧语法

我的Rails 3的routes.rb与

开始
ApplicationName::Application.routes.draw do 

滑轨从外部路由:http://guides.rubyonrails.org/routing.html

+0

好!现在到下一个问题(ps。我忘了'.draw'和我正在做'map.resources') –

0

只是为了确保,你有没有尝试过重新启动的WEBrick(或任何其他的服务器你使用) 。虽然这是非常简单的,它总是会让你绊倒:)

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

编辑:刚刚看到您的帖子的更新。尝试一行一行地删除路由文件中的其他(未注释的)行,直到问题得到解决。

+0

是试图一行一行地删除,但仍然没有..我的日志Containts this:'开始GET“/”为192.168.1.114在8月18日星期四17: 17:10 +0000 2011 ActionController :: RoutingError(没有路由匹配“/”):'(加上一堆其他错误,但这些警告,因为一些轨道2东西arent与轨道3工作,没有影响找到路线的项目} –

0

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

,并在顶部的ressources应该只是:

resources :users 
    resources :sessions 
+0

did not think so,but still didnt solve the routing problem .. –

0

尝试:

root :to => 'home#index' 

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

+0

好,但是,仍然没有解决问题,在浏览器中保存消息并记录:'ActionController :: RoutingError(No route mat ches“/”):' –