Here’s another simple plugin hot on the heels of my previous ExceptionTextable plugin: A plugin to add redirects straight in your routes.rb file.
First, to install say:
script/plugin source http://svn.pinds.com/rails/plugins script/plugin install redirect_routing
Then add this to your routes.rb:
map.redirect '', :controller => 'events'
And now the root of your site will redirect to the index action of the events controller.
Why not just map.connect? Because map.connect causes the URL in the browser to stay at /, which isn’t very RESTful.
Note that you can also pass a string:
map.redirect 'lars', 'http://pinds.com'
Now /lars will redirect to my blog.
See the README for more details. Enjoy!

1 Pelle // Jul 19, 2006 at 01:03 AM
2 Jarkko Laine // Jul 19, 2006 at 09:07 PM
Ok, maybe that was a bit too involved... but it *would* make supporting textpattern-type url's easy in Typo :-)map.redirect 'blog/:id', Proc.new{|id| @post = Post.find(id) {:day => @post.day, ... , :title => @post.title} }3 Lars Pind // Jul 19, 2006 at 11:07 PM
4 Thijs van der Vossen // Jul 20, 2006 at 09:06 AM
5 Lars Pind // Jul 20, 2006 at 09:17 AM
6 robin // Jul 30, 2006 at 08:13 PM
7 Lars Pind // Jul 30, 2006 at 08:27 PM
8 Daniel Butler // Sep 19, 2006 at 06:01 PM
9 Craig Barber // Mar 20, 2007 at 05:06 PM
10 Lee Iverson // May 10, 2007 at 10:44 AM
module RedirectRouting module Routes def redirect(path, options={}) url_options = { } connect_options = { :controller => "redirect_routing", :action => "redirect", :url_options => url_options } options.each do |key,value| if [:controller, :action].include?(key) url_options[key] = value else connect_options[key] = value end end connect path, connect_options end end endandclass RedirectRoutingController < ActionController::Base def redirect url_options = params.delete(:url_options) redirect_to params.merge(url_options) end end11 Michael Hartl // Aug 06, 2007 at 06:44 PM
12 Lars Pind // Aug 08, 2007 at 10:15 AM
13 Ian Heggie // Oct 17, 2007 at 10:58 AM
14 Neil Smith // Dec 13, 2007 at 04:14 PM
15 Neil Smith // Dec 13, 2007 at 04:18 PM