我一直在做树屋练习,构建一个Rails应用程序来进行状态更新。我能够进入0.0.0.0:3000,但我仍然无法进入0.0.0.0:3000/statuses。以下是我的终端输出:
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)
当我转到0.0.0.0:3000/statuses时,我的浏览器会说:
0.0.0.0:3000/stauses:
Routing Error
No route matches [GET] "/statuses" Try running rake routes for more information on available routes.
**我尝试运行rake routes
并尝试rake:db migrate
,然后输入rails server
,但这些都没有效果。有什么想法吗?
答案 0 :(得分:1)
将其添加到routes.rb
文件夹中的config
。
resources :statuses
并确保您有一个名为statuses_controller.rb
的控制器和一个views/statuses/index.html.erb
答案 1 :(得分:0)
在routes.rb文件中添加以下条目:
{ get "statuses" => 'statuses#index'}
如果您在app / controller文件夹中有statuses-controller.rb,在app / views / statuses文件夹中有index.html.erb文件,这将有效。