Jonah Katz
Jonah Katz

Reputation: 5288

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

Upvotes: 1

Views: 388

Answers (4)

Craig Stuntz
Craig Stuntz

Reputation: 126547

Try:

root :to => 'home#index'

Note single quotes. # has special meaning in a double quoted string in Ruby.

Upvotes: 0

inntran
inntran

Reputation: 1033

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

Upvotes: 5

tmaximini
tmaximini

Reputation: 8503

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

Upvotes: 0

hrickards
hrickards

Reputation: 1071

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.

Upvotes: 0

Related Questions