Rails Server Routing Error

2019-08-17 01:31发布

问题:

I am getting a routing error when trying to access the web application with the URL for the localhost.

Ruby on Rails 3.2 and Windows 7 is used.

The Question:

Why does this routing error happen? And does anybody have a suggestion how to fix this?

The URL:

http://localhost:3000/web_app_name

The Error Message:

In the Web Browser:

Routing Error

No route matches [GET] "/web_app_name"

In the Command Prompt:

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)

Addendum:

The "routes.rb" File:

web_app_name/config/routes.rb

WebAppName::Application.routes.draw do

end

The rake routes Command:

The rake routes command does not produce an output in the command prompt.

回答1:

Did you add the route in routes.rb file ?! Show it, please!

It should be something like:

root :to => "controller_name#action_name"