Class: ActiveRecord::Errors
- Inherits:
-
Object
- Object
- ActiveRecord::Errors
- Defined in:
- lib/restfulx/active_foo.rb
Overview
Add more extensive reporting on errors including field name along with a message when errors are serialized to XML
Instance Method Summary collapse
-
#to_fxml(options = {}) ⇒ Object
Flex friendly errors.
Instance Method Details
#to_fxml(options = {}) ⇒ Object
Flex friendly errors
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/restfulx/active_foo.rb', line 160 def to_fxml(={}) [:root] ||= "errors" [:indent] ||= 2 [:builder] ||= Builder::XmlMarkup.new(:indent => [:indent]) [:builder].instruct! unless .delete(:skip_instruct) [:builder].errors do |e| # The @errors instance variable is a Hash inside the Errors class @errors.each_key do |attr| @errors[attr].each do |msg| next if msg.nil? if attr == "base" [:builder].error("message" => msg) else fullmsg = @base.class.human_attribute_name(attr) + ' ' + msg [:builder].error("field" => attr.camelcase(:lower), "message" => fullmsg) end end end end end |