Module: ErrorMessagesHelper
- Defined in:
- lib/generators/nifty/layout/templates/error_messages_helper.rb
Defined Under Namespace
Modules: FormBuilderAdditions
Instance Method Summary collapse
-
#error_messages_for(*objects) ⇒ Object
Render error messages for the given objects.
Instance Method Details
#error_messages_for(*objects) ⇒ Object
Render error messages for the given objects. The :message and :header_message options are allowed.
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/generators/nifty/layout/templates/error_messages_helper.rb', line 3 def (*objects) = objects. [:header_message] ||= "Invalid Fields" [:message] ||= "Correct the following errors and try again." = objects.compact.map { |o| o.errors. }.flatten unless .empty? content_tag(:div, :class => "error_messages") do list_items = .map { |msg| content_tag(:li, msg) } content_tag(:h2, [:header_message]) + content_tag(:p, [:message]) + content_tag(:ul, list_items.join.html_safe) end end end |