Revert params.fetch to params.expect conversions in scaffold#52932
Conversation
|
I think you need something like this to fix tests: jeromedalbert@e5119cf |
1aca62c to
c9f9772
Compare
Yes, of course. Thank you again, @jeromedalbert. That's what I get for coding in a hurry between other things. Updated and tested locally. Should be good now. |
c9f9772 to
06d034b
Compare
|
Updated again to add a test that was missing for api controller generation. |
The conversions have the unintended consequence of requiring params when none are expected. Ensure generated templates work as is. Adds a missing test for the api controller generation. Originally pointed out in rails/jbuilder#573.
06d034b to
1929503
Compare
|
Current edgeguides suggest us to use But the template for controller has been updated to use @martinemde do you have any thoughts to resolve the inconsistency? |
|
@hachi8833 The reason it was reverted here is that This is not, in fact, an inconsistency. All generated scaffolds will use tl;dr: Always use |
|
@martinemde I got it, thank you! 😂 |
|
@hachi8833 awesome, thanks for asking. This revert here was actually me catching a mistake in my first PR and fixing it real quick. 😄 |
|
@hachi8833 If you're interested, I wrote an article about how to use |
Motivation / Background
In rails/jbuilder#573 we stumbled on the case where the scaffold was generating
params.expect(table_name: {})which has the unintended consequence of requiring that a param is given when there are no expected params.Detail
This PR reverts 2 small changes to the scaffold templates introduced by #51674 so that default scaffolds don't return 400 Bad Request upon creation with no attributes.
Additional information
Thanks to @jeromedalbert for noticing that I had made the very changes that I pointed out as problematic in his PR in jbuilder. Teamwork!
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]