Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Allow destroy routes to point at update actions. #251

Open
jimsynz opened this issue Oct 31, 2024 · 1 comment
Open

Allow destroy routes to point at update actions. #251

jimsynz opened this issue Oct 31, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@jimsynz
Copy link
Contributor

jimsynz commented Oct 31, 2024

Is your feature request related to a problem? Please describe.
My resource has the following update action:

update :close do
  change set_attribute(:status, "closed")
end

When exposing it via JSON:API I think the most reasonable thing to do is expose it as a DELETE endpoint.

Describe the solution you'd like
Allow delete route entities to accept update actions in addition to destroy and generic actions.

Describe alternatives you've considered

routes do
  base "/tickets"
  patch :close, route: "/:id/close"
end

Express the feature either with a change to resource syntax, or with a change to the resource interface

routes do
  base "/tickets"
  delete :close
end

Additional context
🐚

@jimsynz jimsynz added enhancement New feature or request needs review labels Oct 31, 2024
@zachdaniel
Copy link
Contributor

Makes sense to me. In the short term, you could make your update action a destroy action with `soft? true.

destroy :close do
  soft? true
  change set_attribute(:status, "closed")
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Someday
Development

No branches or pull requests

2 participants