ruby on rails - How to prevent to_xml from (wrongly) singularize tags? -


string xml:

>> obj = hash.from_xml('<addresses><address><name>1</name></address><address><name>2</name></address></addresses>') => {"addresses"=>{"address"=>[{"name"=>"1"}, {"name"=>"2"}]}} 

address (wrongly) becomes addres (missing s surrounding <name> tag):

>> print obj.to_xml <?xml version="1.0" encoding="utf-8"?> <hash>   <addresses>     <address type="array">       <addres>         <name>1</name>       </addres>       <addres>         <name>2</name>       </addres>     </address>   </addresses> </hash> => nil 

how can disable to_xml regularizing tags?

update:

added in config/initializers/inflections.rb :

activesupport::inflector.inflections |inflect|  inflect.irregular 'address', 'addresses' end 

but still gives same addres tag.

i'm guessing to_xml references attempts intelligent pluralizations. might want try adding line config/initializers/inflections.rb persuade act otherwise.

something

inflect.irregular 'address', 'addresses' 

perhaps?


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -