Closed key88sf closed 2 years ago
@key88sf - your controller has to respond with code 422 if you want errors to render correctly. Without posting your controller code its impossible to help.
if @image.save
redirect_to @image, notice: 'Image successfully created.', status: :see_other
else
render :new, status: :unprocessable_entity
end
This is a duplicate of #1754 and should be closed.
@danielricecodes Ah yes - the status:
is what was missing on the controller side. Thank you for flagging that.
Environment
Current behavior
Using a basic input form in a Rails view for a model:
When there are errors on the model (e.g. create fails due to a validation error on the URL in this case), there are no error classes or visual indication added to the form HTML.
In order to get this to work, Turbo has to be turned off for the form submission:
= f.button :submit, data: { turbo: false }
Expected behavior
Would like SimpleForm to "just work" and show validation errors when Turbo is enabled (which it is by default) in Rails 7 apps.