Class: RPH::FormAssistant::FieldErrors
- Inherits:
-
Array
- Object
- Array
- RPH::FormAssistant::FieldErrors
- Defined in:
- lib/form_assistant/field_errors.rb
Overview
extensions for formatting error messages
Ex: <%= errors %>
<%= errors.to_s(:break => true) %>
<%= errors.to_list %>
<%= errors.to_list(:class => 'errorz') %>
Instance Method Summary collapse
-
#to_list(options = {}) ⇒ Object
converts an array into an unordered list.
- #to_s(options = {}) ⇒ Object
Instance Method Details
#to_list(options = {}) ⇒ Object
converts an array into an unordered list
16 17 18 19 20 21 22 23 24 |
# File 'lib/form_assistant/field_errors.rb', line 16 def to_list( = {}) css_class = .delete(:class) || 'errors' list_items = self.inject("") do |items, error| items << "<li>#{error}</li>" end return '<ul class="%s">%s</ul>' % [css_class, list_items] end |
#to_s(options = {}) ⇒ Object
10 11 12 13 |
# File 'lib/form_assistant/field_errors.rb', line 10 def to_s( = {}) return self.join('<br />') if [:break] self.to_sentence end |