Created
January 7, 2011 16:11
-
-
Save ckdake/769663 to your computer and use it in GitHub Desktop.
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 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 |
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
I was battling with things to get full html_safe content as just nesting like content_tag(:div, [content_tag(:h1, "h1"), content_tag(:h1,"h1 again")]).html_safe ends up with escaped html brackets on the h1s. Probably not needed!