Last active
August 29, 2015 14:14
-
-
Save HammerInTheNews/350cb97b7e2221a734de to your computer and use it in GitHub Desktop.
Add error message handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this in the form_for loop after "do" | |
<%= render 'shared/errors', object: @object_name %> | |
# Then in the shared/errors partial put: | |
<% if object.errors.any? %> | |
<section id="errors"> | |
<header> | |
<h2> | |
Oops! The <%= object.titleize.downcase %> could not be saved. | |
</h2> | |
<h3> | |
Please correct the following <%= pluralize(object, "error") %>: | |
</h3> | |
</header> | |
<ul> | |
<% object.errors.full_messages.each do |message| %> | |
<li><%= message %></li> | |
<% end %> | |
</ul> | |
</section> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment