This post originated from an RSS feed registered with Ruby Buzz
by Jeremy Voorhis.
Original Post: Announcing resource_hacks
Feed Title: JVoorhis
Feed URL: http://feeds.feedburner.com/jvoorhis
Feed Description: JVoorhis is a Rubyist in northeast Ohio. He rambles about Ruby on Rails, development practices, other frameworks such as Django, and on other days he is just full of snark.
resource_hacks is a plugin that extends edge Rails’ new restful routes implementation. While the current opinion of the core team is that we should only use member resources with a numeric id, resource_hacks allows Rails to support arbitrary an arbitrary member path. Allow me to illustrate:
map.resources :entries
gives us the member path /entries/1 where 1 is the value of params[:id]. With resource_hacks, you can still use a numeric id, but also declare an arbitrary member path like so:
This gives us the member path /entries/2006/8/1/announcing_resource_hacks rather than /entries/1.
With this routing definition, you may send an HTTP request with the PUT method to update the Entry via EntriesController#update. The same goes for DELETE. The collection found at /entries will not be affected by resource_hacks.
One final note: I cannot take full credit for this plugin. The basic implementation came from Andrew Grim, PLANET ARGON’s latest developer. Welcome, Andrew!