szatan szatan - 3 months ago 14x
Ruby Question

Routing Error No route matches [GET] "/static_pages/home", tutorial

When I run server browser show me something like this:

Routing Error

No route matches [GET] "/static_pages/home"

Try running rake routes for more information on available routes.

Rake routes shows me this:

root / static_pages#home
help /help(.:format) static_pages#help
about /about(.:format) static_pages#about
contact /contact(.:format) static_pages#contact

My routes.rb file:

MyApp::Application.routes.draw do
root :to => 'static_pages#home'

match '/help', :to => 'static_pages#help'
match '/about', :to => 'static_pages#about'
match '/contact', :to =>'static_pages#contact'


Anyone got an idea?


There is no route set for the url '/static_pages/home'

Although root points to static_pages controller with action home, it still responds to the path '/' and not '/static_pages/home'

If you add

match '/static_pages/home', :to =>'static_pages#home'

You will get the expected response for '/static_pages/home'