errors#add is to use << to append a message to the errors.messages array for an attribute: - Rails Guide errors.messages[:name] << "foo" * obviously not accurate @lulalala_it 29
with Error objects? » Can we copy the Error object and append it to parent? » Message rendering would break, because parent does not have that attribute. » Introducing NestedError @lulalala_it 53
and wraps it as NestedError def import(error, override_options = {}) @errors.append( NestedError.new(@base, error, override_options) ) end @lulalala_it 55
with ^, and will skip prefix if it is. validates_acceptance_of :terms_of_service, message: '^Please accept the terms of service' But this can have edge case bug too. @lulalala_it 58
defined to remove and add default proc. def marshal_dump # :nodoc: [@base, without_default_proc(@messages), without_default_proc(@details)] end def marshal_load(array) # :nodoc: @base, @messages, @details = array apply_default_array(@messages) apply_default_array(@details) end @lulalala_it 75
be customized? » yaml_load? » Wrong! init_with » Totally different interfaces (Rantings: could the interface for Marshal and YAML be unified?) @lulalala_it 84
type = detail.delete(:error) next if type == :too_coooool if type.is_a?(Symbol) model.errors.full_message( attribute, model.errors.generate_message(attribute, type, detail) ) else model.errors.full_message( attribute, type ) end }.compact @lulalala_it 88