ActiveResource in a Flurry

ActiveResource in a Flurry

A look at the Rails Trac’s timeline shows that ActiveResource is undergoing a lot of activity right now, including attention by DHH. Here’s the interesting things I’ve noticed so far:

  • Changeset #6539 - If you save an object, and get an XML body response from the controller, reload the object with the data from that response. So, if the controller performs any machinations on an object while saving it, the client can be informed of the object’s new state.

  • Changeset #6584 - Custom method names for resources. This is a big one. I’m inferring what it does by the CHANGELOG comment:

* Added support for calling custom methods #6979 [rwdaigle] 
     Person.find(:managers)    # => GET /people/managers.xml 
     Kase.find(1).post(:close) # => POST /kases/1/close.xml 

  • Changeset #6579 - This expands the default scaffold_resource controller to respond to new.xml. It will return a new object, in XML form. This can be used by a client to automatically figure out the attributes a model supports. There’s really no code change here to Rails itself, new.xml is given for free if you want it. The significance is that it expands Rails' proposed standard for REST.

So altogether, ActiveResource is getting a lot more fleshed out. I can’t help but expect we’re going to see its public release soon, and this is awesome.

Another note: I’ll be supporting that last one, about new.xml, in Jester in the next release, because I submitted the patch for it myself. It’ll significantly benefit Jester, and I suspect any other non-Ruby ActiveResource client out there. I’ll try to keep Jester up to date with ActiveResource, but that’s looking like a tall order.

Eric Mill Developer