Skip to content

Instantly share code, notes, and snippets.

@ckdake
Created January 7, 2011 16:11
Show Gist options
  • Save ckdake/769663 to your computer and use it in GitHub Desktop.
Save ckdake/769663 to your computer and use it in GitHub Desktop.
module DeviseHelper
def devise_error_messages!
unless resource.errors.empty?
content_tag :div, :id => "error_explanation", :escape => false do
content_tag(:h2, "The following errors were encountered:") +
content_tag(:ul, resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join.html_safe)
end.html_safe
end
end
end
@alindeman
Copy link

Looks like you could probably do something like content_tag(:div, [...], {:id => '...'}, false) .. false being escape = false .. but that's pretty uglified? Maybe Ruby will have named arguments someday :)

Well, actually, named arguments may not help here unless you still used the block syntax or just wanted more clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment