module SimpleForm::Components::Errors
Public Instance Methods
error(wrapper_options = nil)
click to toggle source
# File lib/simple_form/components/errors.rb, line 5 def error(wrapper_options = nil) error_text if has_errors? end
full_error(wrapper_options = nil)
click to toggle source
# File lib/simple_form/components/errors.rb, line 9 def full_error(wrapper_options = nil) full_error_text if options[:error] != false && has_errors? end
has_errors?()
click to toggle source
# File lib/simple_form/components/errors.rb, line 13 def has_errors? object_with_errors? || !object && has_custom_error? end
has_value?()
click to toggle source
# File lib/simple_form/components/errors.rb, line 17 def has_value? object && object.respond_to?(attribute_name) && object.send(attribute_name).present? end
valid?()
click to toggle source
# File lib/simple_form/components/errors.rb, line 21 def valid? !has_errors? && has_value? end
Protected Instance Methods
error_method()
click to toggle source
# File lib/simple_form/components/errors.rb, line 41 def error_method options[:error_method] || SimpleForm.error_method end
error_text()
click to toggle source
# File lib/simple_form/components/errors.rb, line 27 def error_text text = has_custom_error? ? options[:error] : errors.send(error_method) "#{html_escape(options[:error_prefix])} #{html_escape(text)}".lstrip.html_safe end
errors()
click to toggle source
# File lib/simple_form/components/errors.rb, line 45 def errors @errors ||= (errors_on_attribute + errors_on_association).compact end
errors_on_association()
click to toggle source
# File lib/simple_form/components/errors.rb, line 61 def errors_on_association reflection ? object.errors[reflection.name] : [] end
errors_on_attribute()
click to toggle source
# File lib/simple_form/components/errors.rb, line 53 def errors_on_attribute object.errors[attribute_name] || [] end
full_error_text()
click to toggle source
# File lib/simple_form/components/errors.rb, line 33 def full_error_text has_custom_error? ? options[:error] : full_errors.send(error_method) end
full_errors()
click to toggle source
# File lib/simple_form/components/errors.rb, line 49 def full_errors @full_errors ||= (full_errors_on_attribute + full_errors_on_association).compact end
full_errors_on_association()
click to toggle source
# File lib/simple_form/components/errors.rb, line 65 def full_errors_on_association reflection ? object.errors.full_messages_for(reflection.name) : [] end
full_errors_on_attribute()
click to toggle source
# File lib/simple_form/components/errors.rb, line 57 def full_errors_on_attribute object.errors.full_messages_for(attribute_name) end
has_custom_error?()
click to toggle source
# File lib/simple_form/components/errors.rb, line 69 def has_custom_error? options[:error].is_a?(String) end
object_with_errors?()
click to toggle source
# File lib/simple_form/components/errors.rb, line 37 def object_with_errors? object && object.respond_to?(:errors) && errors.present? end