Forum: Ruby on Rails RESTful posting

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
44a43e7fef8e933e802a7802b4bd3525?d=identicon&s=25 John Small (johnsmall)
on 2009-04-18 20:24
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, 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?


John Small
44a43e7fef8e933e802a7802b4bd3525?d=identicon&s=25 John Small (johnsmall)
on 2009-04-19 16:45
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.
This topic is locked and can not be replied to.