What is the preferred way to display validation error messages using form_for in Rails 4?
<%= form_for @post do |f| %>
...
<% end %&g
I know this isn't exactly what was asked, but if you are using the simple_form gem, which I recommend, you can use f.error_notification which takes :message as an option.
= f.error_notification message: form_errors_for(your_object)
I use a method pretty similar to Wes's answer; form_errors_for inside application_helper.rb
def form_errors_for_base(object)
if object.errors.messages[:base].present?
object.errors.messages[:base].join(",\n") + "."
else
nil
end
end