我想将post index页面设为根页面,并将/ posts重定向到根路径 索引的前缀是帖子...... 我在路线中尝试了这个(但我不知道它是否正确)
root "posts#index'
resources :posts, except: [:index]
所以现在我得到索引的根,但/ posts不工作...而不是得到错误,我希望它重定向到根页... 更改我的路线文件后,这是我的帖子路线...
root GET / posts#index
posts POST /posts(.:format) posts#create
new_post GET /posts/new(.:format) posts#new
edit_post GET /posts/:id/edit(.:format) posts#edit
post GET /posts/:id(.:format) posts#show
PATCH /posts/:id(.:format) posts#update
PUT /posts/:id(.:format) posts#update
DELETE /posts/:id(.:format) posts#destroy
答案 0 :(得分:1)
变化
root "posts#index"
resources :posts, except: [:index]
到
root "posts#index"
resources :posts