[typo] Redirects

Scott Laird scott at sigkill.org
Wed Sep 7 14:45:33 EDT 2005

On Sep 7, 2005, at 10:15 AM, Mike Purvis wrote:

> Okay, so I'm tempted to just dash off a quick PHP to make the  
> redirects, but I might as well start getting used to the Rails Way.
> I generated a new controller called "forward". And in routes.rb, I  
> added this:
>  # forward old urls
>  map.connect 'archive/:title',
>    :controller => 'forward', :action => 'forward_old'
> I established it's making it to ForwardController:
> class ForwardController < ApplicationController
>  def forward_old
>    render_text 'Hello'
>  end
> end
> However, I'm unsure how to access the "title" that I've passed in,  
> or indeed how to query the articles table-- one belonging to a  
> different controller. Am I going about this all backwards? Should  
> it be a new action in the Articles controller instead, so that the  
> table I need is just "there"?

Title is in params[:title].  The tie between controllers and models  
is generally explicit (except for scaffolding, but Typo doesn't use  
it).  So you can do something like this:

   def forward_old
     article = Article.find_by_name(params[:title])
     redirect_to article_url(article)


More information about the Typo-list mailing list