# RESTful posting

**URL:** <https://www.ruby-forum.com/t/restful-posting/165878>\
**Category:** Rails\
**Created:** [April 18, 2009, 8:24pm UTC](https://www.ruby-forum.com/t/restful-posting/165878 "2009-04-18T20:24:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [April 18, 2009, 8:24pm UTC](https://www.ruby-forum.com/t/restful-posting/165878/1 "2009-04-18T20:24:58Z")

</div>

I’m implementing a Rails front end to a Windows system by using RESTful  
web services to send data back and forth. Luckyly all the business  
objects in the Windows system know how to serialize themselves into XML  
so it’s not too complicated.

But when I looked at the XML that gets sent back to the service in a  
POST when you do a myresource.save, all the fields that had underscores  
come across with hyphens in place, which is incredibly weird. Is this  
something ActiveResource is doing or is it something happening on the  
Windows side of things?

Ta

John S.

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [April 19, 2009, 4:45pm UTC](https://www.ruby-forum.com/t/restful-posting/165878/2 "2009-04-19T16:45:01Z")

</div>

I’ve half solved my own problem.

ActiveResource#save uses #encode which uses ActiveResource#to\_xml

The documentation for ActiveResource#to\_xml states that :dasherize  
defaults to false. In fact in the code for Hash#to\_xml, which it calls,  
it defaults to true. So #encode calls #to\_xml with the default, hence  
all the underscores in field names on ActiveResources get converted into  
hyphens when you save the record.

I’ve logged a ticket on lighthouse and vendorized rails and made a  
temporary fix to the code for my own setup.

Question is, how come this massive error wasn’t spotted? Well it is a  
show stopper if you’re using ActiveResource to access non-Rails systems  
via REST, but I guess if you aren’t you’d never run into the problem.  
Which to me implies there aren’t many people using REST to do system  
integration between Rails and non-Rails systems.

Are there many people using REST to integrate with non-Rails systems?  
Comments please.
