Routing Error No route matches [GET] "/statuses" Treehouse

4.7k Views Asked by At

I have been doing the Treehouse exercise on building a Rails app to do status updates. I was able to go to 0.0.0.0:3000 but I am still unable to go to 0.0.0.0:3000/statuses. The following is my Terminal output:

Started GET "/statuses" for 127.0.0.1 at 2013-04-22 02:32:07 -0700

ActionController::RoutingError (No route matches [GET] "/statuses"): actionpack (3.2.12)       lib/action_dispatch/middleware/debug_exceptions.rb:21:in call' actionpack (3.2.12) lib/action_dispatch/middleware/show_exceptions.rb:56:incall' railties (3.2.12) lib/rails/rack/logger.rb:32:in call_app' railties (3.2.12) lib/rails/rack/logger.rb:16:inblock in call' activesupport (3.2.12) lib/active_support/tagged_logging.rb:22:in tagged' railties (3.2.12) lib/rails/rack/logger.rb:16:incall' actionpack (3.2.12) lib/action_dispatch/middleware/request_id.rb:22:in call' rack (1.4.5) lib/rack/methodoverride.rb:21:incall' rack (1.4.5) lib/rack/runtime.rb:17:in call' activesupport (3.2.12) lib/active_support/cache/strategy/local_cache.rb:72:incall' rack (1.4.5) lib/rack/lock.rb:15:in call' actionpack (3.2.12) lib/action_dispatch/middleware/static.rb:62:incall' railties (3.2.12) lib/rails/engine.rb:479:in call' railties (3.2.12) lib/rails/application.rb:223:incall' rack (1.4.5) lib/rack/content_length.rb:14:in call' railties (3.2.12) lib/rails/rack/log_tailer.rb:17:incall' rack (1.4.5) lib/rack/handler/webrick.rb:59:in service' /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:138:inservice' /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:94:in run' /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/server.rb:191:inblock in start_thread'

Rendered /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-3.2.12/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (20.0ms)

When I go to 0.0.0.0:3000/statuses, my browser says:

0.0.0.0:3000/stauses:

Routing Error

No route matches [GET] "/statuses" Try running rake routes for more information on available routes.

** I tried running rake routes and tried rake:db migrate and then typing in rails server but none of those worked. Any thoughts?

2

There are 2 best solutions below

0
On

Add this to your routes.rb in the config folder.

resources :statuses

and make sure you have a controller named statuses_controller.rb and a view at views/statuses/index.html.erb

0
On

Add the following entry in the routes.rb file:

{ get "statuses" => 'statuses#index'}

This will work if you have statuses-controller.rb in app/controller folder and index.html.erb file in the app/views/statuses folder.