Hello,
I’ve read the rails introduction and followed the examples. It was quite understandable. But the form validation didn’t work as expected.
My form begins with
<%= form_with(model: @article) do |form| %>
<% if @article.errors.any? %>
…
and in the class is the validation rule:
validates :title, length: { minimum: 5 }
…
part of the controller:
def update
@article = Article.find(params[:id])
if @article.update(article_params)
redirect_to @article
else
render :edit
end
end
the problem is:
if the title is too short (for example) I can push the update-button but nothing happens. There is no reload of the page at all, no errors are shown. Is the title is long enough, the submit-button works correctly. Do I change the form_with to (scope: :article, …) then the errors are shown.
I use Rails 5.1.4
Thx for a response