I am hitting all kinds of walls trying to stop rails from replacing XML underscores with dashes. I'm doing a post to a web service using ActiveResource. I have tried all kinds of variations of fixes for this, with results varying from rails initialization errors to just no effect. The web service I am posting to requires underscores.
Essentially, if I can get the following in place, I should be good:
From http://rubydoc.info/docs/rails/2.3.8/ActiveResource/Base
:dasherize - Boolean option to determine whether or not element names should replace underscores with dashes. Default is true. The default can be set to false by setting the module attribute ActiveSupport.dasherize_xml = false in an initializer.
Can someone provide an example of this? I'm unfortunately on a tight timeline, so if someone can provide assistance that would be a huge help.
Thanks!
Did you attempt to set the module attribute to false in an initializer?
ActiveSupport.dasherize_xml = false
for rails 3+ you can use the following within your response:
render :xml => object.to_xml(:dasherize => false)
See edit history for ugly monkeypatching approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With