简体   繁体   English

路由错误没有路由匹配[GET]“ / statuses”树屋

[英]Routing Error No route matches [GET] “/statuses” Treehouse

I have been doing the Treehouse exercise on building a Rails app to do status updates. 我一直在进行关于构建Rails应用程序以进行状态更新的Treehouse练习。 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. 我可以转到0.0.0.0:3000,但仍然无法转到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/statuses时,我的浏览器显示:

0.0.0.0:3000/stauses: 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. **我尝试运行rake routes并尝试rake:db migrate ,然后输入rails server但这些都不起作用。 Any thoughts? 有什么想法吗?

Add this to your routes.rb in the config folder. 将此添加到config文件夹中的routes.rb

resources :statuses

and make sure you have a controller named statuses_controller.rb and a view at views/statuses/index.html.erb 并确保您有一个名为statuses_controller.rb的控制器和一个位于views/statuses/index.html.erb

Add the following entry in the routes.rb file: 在routes.rb文件中添加以下条目:

{ 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. 如果您在app / controller文件夹中有statuses-controller.rb,在app / views / statuses文件夹中有index.html.erb文件,则此方法将起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM