diff options
Diffstat (limited to 'app/helpers/application_helper.rb')
| -rw-r--r-- | app/helpers/application_helper.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 22a7940..0be66e9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | # Methods added to this helper will be available to all templates in the application. | 1 | # Methods added to this helper will be available to all templates in the application. |
| 2 | module ApplicationHelper | 2 | module ApplicationHelper |
| 3 | def form_error_messages(form_object) | ||
| 4 | object = form_object.is_a?(ActionView::Helpers::FormBuilder) ? form_object.object : form_object | ||
| 5 | return "" unless object && object.errors.any? | ||
| 6 | content_tag(:div, :class => "error_messages") do | ||
| 7 | content_tag(:ul) do | ||
| 8 | object.errors.full_messages.map do |msg| | ||
| 9 | content_tag(:li, msg) | ||
| 10 | end.join.html_safe | ||
| 11 | end | ||
| 12 | end | ||
| 13 | end | ||
| 3 | end | 14 | end |
