Mon, 19 Mar 07

Monkey patching rails routing

This plugin offers the following two features.

  1. Permanently redirecting requests for urls that end in a slash to the equivalent url with no slash, helping disambiguate urls, as explained by Simon Willison.
  2. The addition of ActionController::Routing::RouteSet::Mapper#permanently_redirect, allowing us to declare permanent redirections within our route config.
ActionController::Routing:Routes.draw do |map|
  map.permanently_redirect 'legacy/view/:id', :controller => 'current', :action => 'show'
end

A quick google reveals that Rob McKinnon has an alternative suggestion for removing the trailing slashes.

The plugin is known to work with Rails 1.1.6.