How to add a custom RESTful route to a Rails app?

后端 未结 4 1289
既然无缘
既然无缘 2021-01-30 01:47

I\'m reading these two pages

  1. resources
  2. Adding more RESTful actions

The Rails Guides page shows

map.resources :photos, :new          


        
4条回答
  •  时光说笑
    2021-01-30 02:43

    If i'm understanding your question right, you just want to rename the urls of the new and create actions.

    This would be done like so:

    map.resources :users, :path_names => {:new => 'signup', :create => 'register'}
    

    If you really would like to add new routes with corresponding controller actions, then Damiens answer is the way to go.

提交回复
热议问题