Created
November 13, 2010 19:55
-
-
Save natebird/675585 to your computer and use it in GitHub Desktop.
Application helper to simplify the views in Rails3
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
# app/helpers/application_helper.rb | |
def form_errors(form) | |
if form.errors.any? | |
content_tag :h2, "#{pluralize(form.errors.count, 'error')} prohibited this #{form.class} from being saved:" | |
content_tag :ul | |
form.errors.full_messages.each do |msg| | |
content_tag :li, msg | |
end | |
end | |
end | |
# View | |
= form_errors(@idea) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment