<%= form_for(@product) do |f| %>
<%= f.error_messages %>
<%= f.label :description %>
<%= f.text_field :description %>
<%= f.label :value %>
<%= f.text_field :value %>
<%= f.submit "Create" %>
<% end %>
If you submit the form with empty fields, the result will be similar to the one shown below:
!images/error_messages.png(Error messages)!
NOTE: The appearance of the generated HTML will be different from the one shown, unless you have used scaffolding. See "Customizing the Error Messages CSS":#customizing-error-messages-css.
You can also use the +error_messages_for+ helper to display the error messages of a model assigned to a view template. It is very similar to the previous example and will achieve exactly the same result.