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

后端 未结 4 1292
既然无缘
既然无缘 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

    The new option allows you to create new routes for creating new objects. That's why they're prefixed with that term.

    What you're looking for is the :collection option.

    map.resources :users, :collection => { :signup => :get, :register => :post }
    

    Which will create the /users/signup and /users/register urls.

提交回复
热议问题