Created
November 10, 2010 03:08
-
-
Save adomokos/670277 to your computer and use it in GitHub Desktop.
Since this was - rightly - removed from Rails 3
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
module ApplicationHelper | |
def error_publisher(model) | |
# Thanks Joe! | |
return unless model.errors.any? | |
item_errors = '' | |
model.errors.full_messages.each do |e| | |
item_errors += "<li>#{e}</li>" | |
end | |
content_tag(:div, :id => 'errors') do | |
"<p>#{pluralize(model.errors.count, 'error')} prohibited this point from being saved:</p>" + | |
"<ul>#{item_errors}</ul>" | |
end | |
=begin | |
#And this is how it looks using haml | |
capture_haml do | |
haml_tag :div, :id => 'errors' do | |
haml_tag :p, "#{pluralize(model.errors.count, 'error')} prohibited this point from being saved:" | |
haml_tag :ul do | |
model.errors.full_messages.each do |msg| | |
haml_tag :li, msg | |
end | |
end | |
end | |
end | |
=end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment