Validation for Edit and New views disappear after adding Ajax

I have a partial form I’m using on an app with ajax. The validation warnings worked well previously (You miss a required field, it tells you there was a problem and with what field). Then I decided to enhance the app with ajax. I use the partial form with javascript for an edit action in the index view. I also use the partial form in html for new.html.erb.

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”, 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” controller block in some way I’m not seeing.