Add more extensive reporting on errors including field name along with a message when errors are serialized to XML and JSON
serialize errors to AMF
# File lib/restfulx/rx_active_record.rb, line 354 def to_amf(options = {}) options[:amf_version] = 3 options[:serializer] ||= RestfulX::AMF::RxAMFSerializer.new options[:serializer].serialize_errors(Hash[*@errors.to_a.flatten]).to_s end
serializer errors to fXML
# File lib/restfulx/rx_active_record.rb, line 330 def to_fxml(options = {}) options[:root] ||= "errors" options[:indent] ||= 2 options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent]) options[:builder].instruct! unless options.delete(:skip_instruct) options[:builder].errors do |e| # The @errors instance variable is a Hash inside the Errors class @errors.each do |attr, msg| next if msg.nil? if attr == "base" options[:builder].error("message", msg.to_s) else options[:builder].error("field" => attr.camelcase(:lower), "message" => msg.to_s) end end end end
serialize errors to JSON
# File lib/restfulx/rx_active_record.rb, line 349 def to_json(options = {}) "{#{'errors'.inspect}:#{to_json_original(options)}}" end