Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support HTTP PATCH just like PUT and DELETE #884

Closed
oneiros opened this issue Sep 3, 2019 · 2 comments
Closed

Support HTTP PATCH just like PUT and DELETE #884

oneiros opened this issue Sep 3, 2019 · 2 comments

Comments

@oneiros
Copy link
Contributor

oneiros commented Sep 3, 2019

Coming from rails I have learned to prefer PATCH over PUT. lucky already supports this somewhat:

  • You can use the patch route helper in your actions.
  • The link helper will generate the correct data-method attribute.
  • Rails-UJS takes care of sending a POST request with the _method parameter.

When the request arrives in lucky, it will not work, though. PATCH is currently not allowed as a method override and thus POST will be assumed for this request. The relevant code is here:

["POST"].includes?(context.request.method) && ["PUT", "DELETE"].includes?(http_method)

In my case this failed more or less silently. I suspect that if there is a matching route with POST even more confusing things could happen.

I would like to see PATCH fully supported just like PUT and DELETE. In fact I already prepared a PR I am happy to send, if you agree.

But I also understand if you want to keep the list of supported HTTP method overrides to a minimum.

@paulcsmith
Copy link
Member

Hi @oneiros I think you're right that we should also allow PATCH as a method override. Happy to accept a PR to add that!

@paulcsmith
Copy link
Member

Closed by #885

Thanks!!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants