当我尝试我的页面,即localhost:3000 / home时 - 显示此错误。
这是控制台中抛出的错误:
ActionController::RoutingError (No route matches [GET] "/home"):
web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:22:in `middleware_call'
web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:13:in `call'
actionpack (4.2.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.2) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.2) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
我认为railties
存在一些问题。但我不确定它是什么?
我的routes.rb的内容:
Rails.application.routes.draw do
get 'static_pages/home'
get 'static_pages/help'
end
答案 0 :(得分:1)
您应该像这样定义您的路线:
get 'home' => 'static_pages#home'
或:
root 'static_pages#home'
如果你想为你的应用程序设置它的根路径。