Add config.default_method_for_update to support PATCH#5130
Conversation
PATCH is the correct HTML verb to map to the #update action. The semantics for PATCH allows for partial updates, whereas PUT requires a complete replacement. Changes: * adds config.default_method_for_update you can set to :patch * optionally use PATCH instead of PUT in resource routes and forms * adds the #patch verb to routes to detect PATCH requests * adds #patch? to Request * changes documentation and comments to indicate support for PATCH This change maintains complete backwards compatibility by keeping :put as the default for config.default_method_for_update.
|
Good patch. |
Add config.default_method_for_update to support PATCH
|
@rinaldifonseca yep. |
|
@rinaldifonseca Yeah, that's a typo on my part. @markiz I don't see the "HTML"-for-"HTTP" typo in the code of the commit. Can you point out where? |
|
I quote your original pull request:
|
|
@dlee |
|
@ncreuschling Thanks, fixed the original pull request as well. |
|
@stevegraham please see the discussion in #505, in particular interpretations of quotes of the spec. And most importantly the quotes from Roy Fielding that helped to definitely lean the discussion. |
|
@fxn i think i should know about #505 as i participated extensively in the comments. why is roy fielding's opinion more relevant than the other 6 authors of rfc2616? presumably because he is the father of REST, but why not ask tim berners-lee as he is the father of the WWW, surely more authoritative? (tongue firmly in cheek). regardless, why is something fielding says in a blog post or mailing list more authoritative than a rfc? should a spec need interpretation? i don't think so. a specification is by definition a precise description of requirements. and can someone actually show a concrete example of a problem this solves? |
|
@stevegraham I can't believe we are onto this again. I'll try to summarize. A specification uses natural language and thus it is subject to the ambiguities of natural language. A RFC is not expressed in the formal language of mathematical logic, so you will agree with me certainly that there may be room for interpretation in some places. This is a case in point. RFC 2616 says "The PUT method requests that the enclosed entity be stored under the supplied Request-URI.". Now almost everyone on planet Earth reads there creation or replacement. Since this is formulated in English some minority (to which you seem to belong) argue that it is ambiguous and that your interpretation leaves room for partial updates in that sentence. OK, a way to settle that? Have the person whose name appears first in the list of authors of RFC 2616 tell us what it means. It means creation or replacement. Period (as he puts it). |
|
@fxn you can't believe that we're onto this again? frankly neither can i. the total amount of people interested in this pull request and having read the passage "The PUT method requests that the enclosed entity be stored under the supplied Request-URI." is far less than "everyone on planet earth", probably < 10 in reality. please spare me your fallacious arguments. also, my position does not rely on the ambiguity of the spec whereas your position in fact does. 2616 is very clear in that "HTTP/1.1 does not define how a PUT method affects the state of an origin server" how much more clear does this have to be? partial updates are allowed. and i ask again WHAT PROBLEM DOES THIS SOLVE? |
|
i just noticed the fielding commentary that @steveklabnik posted in #505 (grep "game over"). that's the first time i have seen fielding specifically address this issue, rather than have tangential comments of his twisted to fit an argument. i'm happy that the supposed ambiguity has been addressed directly, although i do still think the wording is confusing and could do with being clearer. taking fielding's comments on board, rfc2616 contradicts itself. |
|
@stevegraham so from "HTTP/1.1 does not define how a PUT method affects the state of an origin server" you infer partial updates are allowed? Are you serious man? Steve, not me, Roy Fielding is telling your reading of the spec is wrong. Please read rest-discuss, please read O'Reilly's book on REST, and have a pulse about how people think what's PUT. There's consensus about the meaning of PUT. That's my sample, not the people in the PR. The problem this solves is to ease users of Ruby on Rails to follow HTTP semantics, now it's possible but the design should favor PATCH over PUT due to practical needs of most web applications. |
|
@stevegraham ah, you hadn't seen that one! OK, no prob. |
PATCH is the correct HTTP verb to map to the #update action. The
semantics for PATCH allows for partial updates, whereas PUT requires a
complete replacement.
Changes:
This change maintains complete backwards compatibility by keeping :put
as the default for config.default_method_for_update.
(Continuation of Issue #505)
Update: as rinaldifonseca pointed out, there was a typo in the pull request message that said "HTML verb" instead of "HTTP verb".