0

尝试使用localhost 的 URL访问Web 应用程序时出现路由错误。

使用Ruby on Rails 3.2Windows 7

问题:

为什么会发生此路由错误?有没有人建议如何解决这个问题?

网址:

http://localhost:3000/web_app_name

错误信息:

在网络浏览器中:

Routing Error

No route matches [GET] "/web_app_name"

在命令提示符中:

Started GET "/web_app_name" for 127.0.0.1
    ActionController::RoutingError (No route matches [GET] "/web_app_name"):
      actionpack (3.2.9) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/show_exceptions.rb:56:in `ca ll'
      railties (3.2.9) lib/rails/rack/logger.rb:32:in `call_app'
      railties (3.2.9) lib/rails/rack/logger.rb:16:in `block in call'
      activesupport (3.2.9) lib/active_support/tagged_logging.rb:22:in `tagged'
      railties (3.2.9) lib/rails/rack/logger.rb:16:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/request_id.rb:22:in `call'
      rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
      rack (1.4.1) lib/rack/runtime.rb:17:in `call'
      activesupport (3.2.9) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
      rack (1.4.1) lib/rack/lock.rb:15:in `call'
      actionpack (3.2.9) lib/action_dispatch/middleware/static.rb:62:in `call'
      railties (3.2.9) lib/rails/engine.rb:479:in `call'
      railties (3.2.9) lib/rails/application.rb:223:in `call'
      rack (1.4.1) lib/rack/content_length.rb:14:in `call'
      railties (3.2.9) lib/rails/rack/log_tailer.rb:17:in `call'
      rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
      C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `servi        ce'
      C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
      C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in         start_thread'
      Rendered C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (78.0ms)

附录:

“routes.rb”文件:

web_app_name/config/routes.rb

WebAppName::Application.routes.draw do

end

rake routes 命令:

rake routes命令不会在命令提示符中产生输出。

4

1 回答 1

0

您是否在文件中添加了路线routes.rb?!请出示一下!

它应该是这样的:

root :to => "controller_name#action_name"
于 2012-11-25T20:53:44.030 回答