Rails应用程序显示错误的根页面

时间:2017-04-05 10:33:18

标签: ruby-on-rails routing

所以我在我的路线中有这个:

resources :articles
root 'articles#new'

但我希望我的网址看起来不像 domain / articles / 1 ,但是喜欢 domain / 1 。 所以我将路线改为:

resources :articles, path: ''
root 'articles#new'

它将我的根页面更改为'文章#index',但我仍然希望它是'文章#new'。 我该如何解决?

1 个答案:

答案 0 :(得分:0)

好的,我刚刚将代码更改为:

root 'articles#new'
resources :articles, path: ''

它有效