>> Either use a regex to match the parameter (and then send it to a >> different controller action) or have a single controller action that >> runs both find_by_permalink and find_by_id. > > I have added this to the controller which seems to work well, as my > regex writing is weak. > > @article = Article.find_by_permalink(params[:id]) > unless @article > @article = Article.find(params[:id]) > end
I'd recommend a slightly different approach. Setup an "old_article" route in routes.rb that explicitly matches those old urls... Something like (for 2.x): map.old_article '/articles/:id', ..., :requirements => {:id => /\d+-.*/} Then, in the action for old_article you can find the article and *301* redirect it to the new article URL. Doing this will get you a little SEO boost from Google. Or rather... they won't punish you for duplicate content... If you're using Rails 3, the syntax will change a bit and you could probably put it all in the routes file using the new redirect stuff. Maybe. Hope this helps... -philip -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.