开发者

Use underscores instead of dashes with ActiveResource XML (set :dasherize to false)

开发者 https://www.devze.com 2023-02-20 09:30 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消