Module: FormErrorsHelper
- Defined in:
- app/helpers/form_errors_helper.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #error_span(attribute, options = {}) ⇒ Object
- #errors_for(attribute) ⇒ Object
- #errors_on?(attribute) ⇒ Boolean
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
4 5 6 |
# File 'app/helpers/form_errors_helper.rb', line 4 def object @object end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
3 4 5 |
# File 'app/helpers/form_errors_helper.rb', line 3 def template @template end |
Instance Method Details
#error_span(attribute, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/helpers/form_errors_helper.rb', line 6 def error_span(attribute, = {}) [:class] ||= 'help-inline' template.content_tag( :span, self.errors_for(attribute), :class => [:class] ) if self.errors_on?(attribute) end |
#errors_for(attribute) ⇒ Object
19 20 21 |
# File 'app/helpers/form_errors_helper.rb', line 19 def errors_for(attribute) self.object.errors[attribute].try(:join, ', ') end |
#errors_on?(attribute) ⇒ Boolean
15 16 17 |
# File 'app/helpers/form_errors_helper.rb', line 15 def errors_on?(attribute) self.object.errors[attribute].present? if self.object.respond_to?(:errors) end |