Saturday, December 15, 2007

Snazzy Resource

Josh Kleinpeter and I wrote a cool plugin.

ActiveResource is wicked spiffy, but the reality is that the most obvious use cases all blow up like kaboom. You can't do find(:include), you can't use form handlers without a little bit of meta and a whole lotta luck, and you can't just save an ActiveResource model across the network with all its association classes...

Until now.

Snazzy Resource is a Rails plugin that allows an ActiveRecord model to instantiate and save itself - the equivalent of a create or create! - from the params you'll automatically receive by default from any ActiveResource model saving itself via PUT which happens to contain association classes. All you have to do in your receiving-end controller is:


Save as normal from your ARes client:{"attribute" => "data"}).save

And all the other magic happens for you.

Start here:

script/plugin install

Snazzy camper pic by i_y_e_r_s on flickr

(All the other saving-across-the-network magic, that is. I'm hoping to plugin-ize my ActiveResource schema dumper, and a find(:include) implementation. Stay tooned.)