routes.rb:
resources :articles, path: "news"
rake routes
打印的結果:
articles GET /news(.:format) articles#index
POST /news(.:format) articles#create
new_article GET /news/new(.:format) articles#new
edit_article GET /news/:id/edit(.:format) articles#edit
article GET /news/:id(.:format) articles#show
PUT /news/:id(.:format) articles#update
DELETE /news/:id(.:format) articles#destroy
訪問的地址:
http://localhost:3000/news
以下是報錯信息:
Routing Error
No route matches {:action=>"show", :controller=>"articles"}
Try running rake routes for more information on available routes.