This post originated from an RSS feed registered with Ruby Buzz
by Jeremy Voorhis.
Original Post: What's New in Edge Rails: Restful Routes
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.
simply_restful began its life as a plugin, and at RailsConf, the core team announced that it would be merged into Rails core.
simply_restful has been merged into Rails core. Its functionality seems basically intact, with one minor adjustment: resource names are now pluralized. This means that in your routes.rb file, you must specify
map.resource :entries
instead of
map.resource :entry
The same goes for the companion method resources, which allows you to declare multiple resources at once.
In addition to providing clean URLs which respond to multiple HTTP methods, simply_restful also allows you to specify additional actions which respond to certain verbs like so:
In this case, the url /comments/1;approve would be created. The rationale is to use the path to the left of the semicolon for a resource’s identity, and to use the path to the right of the semicolon as a modifier. Frequently this modifier would be an operation that you would perform on the resource, such as approving a comment that requires moderation.
In the plugin version of simply_restful, there was a bug which allowed only one additional action per HTTP method – you could not have two semicolon-style URLs which accepted the GET method, for example. This bug has been fixed.
I have yet to verify whether the pluralization issue affects this incarnation of simply_restful, but this would be a good time to release a plugin of my own that scratches an itch of mine since the plugin was released.
1 While the Rails changeset log is certainly available for everyone to read, Ryan provides a good service for anyone who wants a periodical synopsis of the latest changes, rather than a constant trickle. Thanks, Ryan!