I’m developing a project using rails 8.04 and ruby 3.4.2 on a MacBook Pro with a Apple M2 Chip.
I am unable to delete a table row using the technique from Rails Getting Started. It specifies to use:
I’ve read through this three times, hoping to spot an issue, but I don’t see it. This should just work,
The only thing I can imagine is that your JavaScript isn’t loading properly. Do you get a confirm dialog after clicking that button?
The fact that you are seeing it as a DELETE means that the JS is there, though, because otherwise it would come in as a POST by default.
Two things to try:
Scaffold a new resource like rails generate scaffold widget name and run the migrations. Restart the app and make a new widget, then go to /widgets and try deleting it there. If that works, then try to spot what’s different in the routes.rb or the generated controller.
Use rails new to make a whole other ‘stunt app’, run the scaffold within it, and see if you can delete those objects. Just use the defaults, don’t try to do anything manually. Again, if that works, then compare the two and see what is implemented differently.
This is such basic, core functionality, and you appear to have done nothing wrong.
Walter thank you for replying to this post. I revisited the problem again. I was feeling there was something I wasn’t see that kept the controller from reaching the method. That was due to my not having a method on something else and I got the same message. Low and behold I was missing an end on the method above. Not sure why I didn’t get an error for that but I put the end in and fixed the issue. Makes me remember the time I coded a l r15,8 instead of la r15,8 (IBM Assembler) which was intended to put a Return value of 8 into Register 15 but I put the word value at real address 8 into Register 15 which produced unintended consequences. Spent hours looking at it and a co-worker walked in and saw it right a way. Happens, you get fixated!