I use the standard bootstrap form, the fields are validated and an error message is displayed. Currently implemented as:

<% if @stock.errors.any? %> <div id="error_explanation"> <h2> <%= pluralize(@stock.errors.count, "error") %> prohibited this stock from being saved: </h2> <ul> <% @stock.errors.full_messages.each do |msg| %> <li><%= msg %></li> <% end %> </ul> </div> <% end %> <br> <%= form_for :stock, url: stocks_path do |f| %> .... <% end %> 

Messages go out but the form begins to disperse, those fields that have not passed validation are wrapped in a div tag with the class field_with_errors

 <div class="field_with_errors"> <label class="col-2 col-form-label" for="stock-name">Name</label> </div> 

How to fix this, and better to make validation error messages like in Bootstrap

It is clear that you can attach the bootstrap styles to the field_with_errors class, but I want to use the bootstrap classes on the contrary.

    1 answer 1

    In the environments/development.rb file, override this method

     config.action_view.field_error_proc = Proc.new { |html_tag, instance| html_tag } 

    Here is a more complete answer.