RESTful posting

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 S.

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs