Skip to content

Instantly share code, notes, and snippets.

@adomokos
Created November 10, 2010 03:08
Show Gist options
  • Save adomokos/670277 to your computer and use it in GitHub Desktop.
Save adomokos/670277 to your computer and use it in GitHub Desktop.
Since this was - rightly - removed from Rails 3
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