No route matches "/"?
I know this seems like a very simple error but its coming from a complex process.
Im trying to upgrade an old rails 2 app to rails 3. In my routes.rb file, i have
root :to => "home#index"
And I also have a file 'app/controllers/home_controller.rb' and a 'app/views/home/index.html.erb' so i simply dont get what could be causing this error. Upgrading to rails 3 isnt easy.
( in the home_controller.rb, i have def index
end
)
Any suggestions?
**UPDATE - FULL ROUTES FILE**
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 nam开发者_如何学运维ed 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
The "map.connect", "map.resources" are old syntax
My Rails 3 routes.rb starts with
ApplicationName::Application.routes.draw do
Rails Routing from the Outside In: http://guides.rubyonrails.org/routing.html
Just to make sure, have you tried restarting Webrick (or whatever other server you're using). While this is very simple, it will always end up tripping you up :)
If that's not the problem, please post your log files (log/development.log).
Edit: Just seen the update to your post. Try removing the other (uncommented) lines in your routes file, line by line, until the problem is fixed.
remove the two map.connect statements. you don't need them in rails3.
and the ressources at the top should be just:
resources :users
resources :sessions
Try:
root :to => 'home#index'
Note single quotes. #
has special meaning in a double quoted string in Ruby.
精彩评论