Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Display error messages as html_safe
Browse files Browse the repository at this point in the history
  • Loading branch information
sodabrew committed Jan 19, 2014
1 parent 74f5ca9 commit d7ae54a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ def inspector_table(collection, key=nil, value=nil, options={})

def error_messages_for(object_name, options)
objects = [options.delete(:object)].flatten
count = objects.inject(0) {|sum, object| sum + object.errors.count }
count = objects.sum {|object| object.errors.count}

return '' if count.zero?

header_message = "Please correct #{count > 1 ? "these #{count} errors" : 'this error'}:"
error_messages = objects.sum {|object| object.errors.full_messages.map {|msg| content_tag(:li, h(msg)) } }.join
error_messages = objects.map {|object| object.errors.full_messages.map {|msg| content_tag(:li, h(msg)) } }.join.html_safe

contents = content_tag(:h3, header_message) +
content_tag(:ul, error_messages)

content_tag(:div, contents, :class => 'errors element')
content_tag(:div,
content_tag(:h3, header_message) +
content_tag(:ul, error_messages) ,
:class => 'errors element')
end

def active_if(condition)
Expand Down

0 comments on commit d7ae54a

Please sign in to comment.