When I was writing the test code and tried to display the error message, I didn't understand it, so keep a record.
In the view directory
<% if model.errors.any? %> <div id="error_explanation" class="alert alert-danger"> <ul> <% model.errors.full_messages.each do |message| %> <li><%= message %></li> <% end %> </ul> </div> <% end %>
And call it with the
The model on the first line is supposed to register something in the database this time.
<%= render 'error_messages', model: f.object %>
Depending on the location of the file, you need to specify something like
shared / error_messages.