What is the preferred way to display validation error messages using form_for in Rails 4?
<%= form_for @post do |f| %>
  ...
<% end %>
                This is how I am displaying them for my form object called @location: 
<% if @location.errors.any? %>
<ul>
  <% @location.errors.full_messages.each do |msg| %>
    <li><%= msg %></li>
  <% end %>
</ul>
<% end %>
Note: put the above code after the <%= form_for @location do |f| %> line
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With