But after configuring for ajax, neither the edit action nor the new action will display validation errors. They just won’t take the change, give no explanation. If I then add the missing field, it is created/updated and I get the notice that it was created/updated successfully. I’m stumped.
This is the form partial:
This is the controller:
This the edit.js.erb file:
I have read a lot of articles and most of them seem to resolve with the controller action needing “render :new”. But that’s not solving it for me.
I think the key is:the submit the button is hit and the controller block executes “if @cocktail.save”, the model sees that the required fields are not all filled out, and @cocktail has errors. But it needs the page to be re-rendered for the “if cocktail.errors.any?” block in the view to execute. So I think I need to move the “if cocktail.errors.any?” block to a different area? Or perhaps change the “if @cocktail.save” controller block in some way I’m not seeing.