Mephisto routes hack refactored

Posted by joe Wednesday, November 01, 2006 02:12:00 GMT

I love this community. Where else can you have the guy who wrote the blog engine jump on you for doing it wrong. Seriously, I’m very appreciative to Rick for showing my why it sucked. I thought this was worth promoting up to a post.

Rick writes:

Yuck, you have rss links pointing to atom feeds? heresy! Anyways, you can probably do something like this instead: Mephisto::Routing.redirect ‘xml/rss/feed.xml’ => ’/feed/rss.xml’, ‘xml/rss20/feed.xml’ => ’/feed/rss.xml’. At least that way you don’t have to worry about what controllers/actions Mephisto is using.

My first thought was that this is something in routes that I was missing. Then after looking at the lib/mephisto/routing.rb file I saw the method he was talking about. So, the routes file now looks like this thanks to Rick:

ActionController::Routing::Routes.draw do |map|
  Mephisto::Routing.redirect 'xml/rss/feed.xml' => "http://feeds.feedburner.com/objo", 
    'xml/rss20/feed.xml' => "http://feeds.feedburner.com/objo" 
  Mephisto::Routing.connect_with map
end

Sweet. If you want to change a redirect make sure to clear the cache of your rss feeds first. If you are looking for good example code of the current state of Rails, check out the mephisto code. It’s fun to look at.

Thanks Rick.