Search code examples
ruby-on-railsrailtie

Ruby On Rails throws error on home - railties


When I try my page i.e, localhost:3000/home - it shows this error.

enter image description here

This is the error thrown in the console:

ActionController::RoutingError (No route matches [GET] "/home"):
  web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:22:in `middleware_call'
  web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:13:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.2) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.2) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.2) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.2) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' 

I think there is some problem with the railties. But I am not sure what it is?

content of my routes.rb :

Rails.application.routes.draw do
  get 'static_pages/home'
  get 'static_pages/help'
end

Solution

  • You should define your route like this:

    get 'home' => 'static_pages#home'
    

    or:

    root 'static_pages#home'
    

    If you want to make it root path for your application.