【发布时间】:2015-05-17 02:11:14
【问题描述】:
当我尝试在 localhost 中加载我的 Rails 应用程序时,我偶尔会收到以下错误。
无效的路由名称,已在使用中:'root' 您可能使用
:as选项定义了两个同名的路由,或者您可能覆盖了已由同名资源定义的路由。对于后者,您可以限制使用resources创建的路由,如下所述:http://guides.rubyonrails.org/routing.html#restricting-the-routes-created
由于某种原因,它只会时不时发生,并且通常会在我刷新一次页面后消失。它所调用的文件有这个作为代码(导致指示错误的行):
Rails.application.routes.draw do
get 'welcome/index'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
Rails.application.routes do
resources :articles
root 'welcome#index' #-->This is the line that causes the error
end
resources :articles do
resources :comments
end
end
我真的是 Rails 的新手,我不确定是什么导致了问题,或者如果我真的在网络上托管这个初学者项目是否会成为问题。另外,如果有帮助,我正在运行 Ruby 2.2.2 和 Rails 4.2.1。
提前感谢您的帮助!
【问题讨论】:
标签: ruby-on-rails ruby