为什么Routes中的Update有PATCH与PUT两种http请求路径

PUT的定义

rfc1945中的定义:

The PUT method requests that the enclosed entity be stored under the
supplied Request-URI. If the Request-URI refers to an already
existing resource, the enclosed entity should be considered as a
modified version of the one residing on the origin server. If the
Request-URI does not point to an existing resource, and that URI is
capable of being defined as a new resource by the requesting user
agent, the origin server can create the resource with that URI.

The fundamental difference between the POST and PUT requests is
reflected in the different meaning of the Request-URI. The URI in a
POST request identifies the resource that will handle the enclosed
entity as data to be processed. That resource may be a data-accepting
process, a gateway to some other protocol, or a separate entity that
accepts annotations. In contrast, the URI in a PUT request identifies
the entity enclosed with the request -- the user agent knows what URI
is intended and the server should not apply the request to some other
resource.
Patch的定义

rfc5789中的定义

Several applications extending the Hypertext Transfer Protocol (HTTP)
require a feature to do partial resource modification.  The existing
HTTP PUT method only allows a complete replacement of a document.
This proposal adds a new HTTP method, PATCH, to modify an existing
HTTP resource.

这里明确指出,因为许多情况下都需要一个去对resource进行局部更改的请求,
而PUT是对一个docuemnt的进行整体替换
所以,就新定义了一个PATCH请求,来专门处理这个有局部请求的request

Rails社区早有讨论

rails issues 348
早先rails 4之前,update都是用的put
而在这个官方issues中,就可以发现针对这个问题,展开了很多讨论,
最后一致认为,PATCH更适合我们的update方法,所以,就把PATCH作为update的默认request方法,
不过由上面的截图也看到了,虽然默认是PATCH,但是,原有的PUT还是得到了保留,
应该是留给你开发者有特殊需求的时候使用的。

Rails官法blog也作出详细解释

Edge Rails: PATCH is the new primary HTTP method for updates | Riding Rails
在看完这篇以后,也对restful有了更清晰的认识
/posts/:id/edit这样的URI分层都属于是资源(resources)分层,
它只有一个目的,就是标注定位,你要操作(CRUD等)的资源文件放在哪的仓库中,
而你要做的操作,也就是action,则由HTTP method来定义,
也就是GET,POST,PUT,PATCH,DELETE这些请求
这些请求更重要的是其语意上的差别,好比是一个统一的规则,
便于所有人进行通用的合作

为何要有这么多method

HTTP中post和put的根本区别和优势? - 知乎
我并不想查太多,不过看一点这篇知乎里Tom Goong的回答,应该能明白一点,这个统一的规则会带来什么好处。