gpt4 book ai didi

ruby-on-rails - 路由错误 No route matches [GET] "/static_pages/home", tutorial

转载 作者:数据小太阳 更新时间:2023-10-29 07:21:03 25 4
gpt4 key购买 nike

当我运行服务器浏览器时,会显示如下内容:

Routing Error

No route matches [GET] "/static_pages/home"

Try running rake routes for more information on available routes.

Rake routes 向我展示了这个:

root  /                  static_pages#home
help /help(.:format) static_pages#help
about /about(.:format) static_pages#about
contact /contact(.:format) static_pages#contact

我的 routes.rb 文件:

MyApp::Application.routes.draw do
root :to => 'static_pages#home'

match '/help', :to => 'static_pages#help'
match '/about', :to => 'static_pages#about'
match '/contact', :to =>'static_pages#contact'


end

有人知道吗?

最佳答案

没有为 url '/static_pages/home' 设置路由

尽管 root 指向具有 action home 的 static_pages Controller ,它仍然响应路径 '/' 而不是 '/static_pages/home'

如果你添加

match '/static_pages/home', :to =>'static_pages#home'

您将获得“/static_pages/home”的预期响应

关于ruby-on-rails - 路由错误 No route matches [GET] "/static_pages/home", tutorial,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11710424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com