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

Scaffold remaining actions and test protocol #203

Merged
merged 9 commits into from
Jul 16, 2022
Merged

Conversation

matthewmueller
Copy link
Contributor

@matthewmueller matthewmueller commented Jul 14, 2022

This PR adds support for the remaining actions. For example, bud new controller posts create update delete edit new.

It also adds method overriding to support PATCH and DELETE requests from form elements: https://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-patch-put-or-delete-methods-work-questionmark

Closes #195
Closes #55
Closes #75

@matthewmueller matthewmueller marked this pull request as draft July 14, 2022 07:25
@jfmario
Copy link
Contributor

jfmario commented Jul 15, 2022

I was poking around at this, and looking at some of the test failures.

One takes place on GET /posts/10 because the test expects an empty object but the controller returns {"id":10} which I think is expected.

The other related error is that PATCH /posts/10 works but not POST /posts/10?_method=patch.

I took a stab at this error in the link below, but I'm sure its not in the correct location.

https://github.com/jfmario/bud/blob/scaffold-actions/package/middleware/method_overload.go

Is this the general idea, though, to put some middleware in front of the router that alters the request method? It was working when I tested locally with ?_method=PATCH.

@matthewmueller
Copy link
Contributor Author

matthewmueller commented Jul 15, 2022

Awesome, thanks for looking into this @jfmario! I'm going to try and wrap this up today.

Is this the general idea, though, to put some middleware in front of the router that alters the request method? It was working when I tested locally with ?_method=PATCH

Yep, exactly. More info here: https://guides.rubyonrails.org/form_helpers.html#how-do-forms-with-patch-put-or-delete-methods-work-questionmark

I'll pull in the code you wrote and make some minor adjustments, but you've got the right idea!

@matthewmueller matthewmueller marked this pull request as ready for review July 16, 2022 02:13
@matthewmueller matthewmueller merged commit b27d768 into main Jul 16, 2022
@matthewmueller matthewmueller deleted the scaffold-actions branch July 16, 2022 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add bud new controller <resource> {create,new,edit,update,delete} actions
2 participants