Update 2007-11-02: Fixed reference to Mephisto author. Thanks Luigi!
Update 2007-11-01: Nathan commented on this post and said m_r will soon support polymorphic routes.
One of the nice features in Ruby on Rails is its support for REST-style controllers. This feature is fledgling in Rails 1.2.3, so if you head down this path you will doubtless find yourself writing a lot of similar-yet-faintly-different code again and again. A number of generous people have written plugins to ease the pain. I did a test run with two lately — make_resourceful and resource_controller — and investigated several others along the way. This is a summary of what I found.
make_resourceful comes from Hampton Catlin (Toronto), Jeff Hardy, and Nathan Weizenbaum, the same crew that does the very cool HAML and SASS plugins. m_r has a pretty syntax, great documentation, and a fairly active google group where Hampton and Nathan engage in discussions. I took it for a test run and quite liked how my code ended up after transmogrification. On the down side, I needed a feature called “polymorphic routes” — e.g. \people\bob\posts or \forums\13\posts — which this plugin doesn’t have built in, but Jonathan Linowes has patched. Alas, I found the combination of the patch and plugin unwieldy: it took me way too long to get it all working for my specific requirements, and the resulting code was, shall we say, Frankensteinesque.
resource_controller is written by Montrealler James Golick, who is buddies with the make_resourceful team members. James’ plugin is quite similar to m_r — the syntax is much the same — and happily for me has built-in support for polymorphic routes. I tried it out and liked the basics, but then found myself stymied by difficulty supporting some custom route formats. I asked James for help, and he was incredibly responsive; he resurfaced just one day later with a new revision that let me customize to my heart’s content. He also made some design changes so that r_c can be instantiated either using inheritance (the original design: your app controller inherits from ResourceController::Base) or as a mixin. These changes are now available in revision 83 of his SVN trunk. James also fired up a google group just recently and takes questions on his blog.
I also looked at:
- resources_controller – from Ian White, who has written several other plugins. (Yes, this plugin has almost the same name as James Golick’s resource_controller. Ian was first.) His plugin looks very functional but I avoided it because I found the syntax unappealing.
- restful_exposure - Luke Redpath. This one didn’t meet my requirements.
- define_crud - SonicIQ. No docs = no soup for you.
Bottom line: I recommend you check out both resource_controller and make_resourceful. I am going with resource_controller for now, since it meets all my requirements and James clearly has a ton of energy around improving it further in the directions I care about. make_resourceful also impressed me a great deal, so if you don’t need polymorphic routes it might be a better solution for you.
make_resourceful will support polymorphic routes in the near future… we just want to get version 0.2.0 out the door soon, and we don’t want to do any drastic code changes before then. But as soon as I get the RDoc up to snuff, we’ll be as polymorphic as you could want.
Thanks for the roundup. Discovering both m_r and r_c has been a godsend.
Just a small correction: Rick Olson authored Mephisto:
http://techno-weenie.net/