How to rename REST routes in URL?

前端 未结 2 1685
野趣味
野趣味 2020-12-25 12:32

Give that I have a model called Apple and it has a controller ApplesController, the routes are:

resources :apples

    apples  GET          


        
2条回答
  •  不知归路
    2020-12-25 12:57

    What you will want to do is pass in the :path option

    resources :apples, :path => "cars"

    This replace all your route references with /apples to /cars

    See: http://guides.rubyonrails.org/routing.html, Section 4.7 Translating Paths

提交回复
热议问题