开发者

Adding a restful route like: /users/234/add_section

开发者 https://www.devze.com 2023-02-28 05:13 出处:网络
I already have: resources :users How can I add a route (for POST only) that will work like: /users/2343/add_section

I already have:

resources :users

How can I add a route (for POST only) that will work like:

/users/2343/add_section

Is it possible to add this route inside of the resources users blo开发者_开发知识库ck?

resources :users do

end


Having add_section there is not very RESTful. Consider having a subresource section and doing POST "/users/123/sections/"


Something like:

  resources :users do
    member do
      post 'add_section'
    end
  end


As I answered on your previous question

resources :users do
  post :add_section, :on => :member
end
0

精彩评论

暂无评论...
验证码 换一张
取 消