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

前端 未结 4 1355
不思量自难忘°
不思量自难忘° 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条回答
  •  不思量自难忘°
    2021-02-20 06:44

    A couple of years and a major version of Rails later, there doesn't seem to be any progress on this issue.

    This did the job for me at the top of routes.rb:

    Rails.application.routes.draw do
      def put(*) end
      ...
    

    Because the set_member_mappings_for_resource method mentioned in the OP's answer calls put, this simply makes it a no-op.

    If you do need put routes, you could put them above this line. If you wanted to be fancy, you could define a without_verbs(*verbs, &block) method that temporarily replaces the various verb methods, yields, and then puts them back.

提交回复
热议问题