Is it possible to disable the standard PUT route in Rails 4?

前端 未结 4 1351
不思量自难忘°
不思量自难忘° 2021-02-20 06:03

Rails 4 has introduced PATCH requests to be the default request method when doing the (common) partial updates on objects. This is conformal to HTTP standards and a

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-20 06:54

    another solution to override PATCH is the following:

    resources :some_resources do
      member { patch action: :event }
    end
    

    This will result in calling the method event on the SomeResourceController when we call this route PATCH /some_resources/:id

    or to disable it:

    resources :some_resource, except: :update do
      member { put action: :update }
    end
    

提交回复
热议问题