Newbie: Simple Routes

Hi,

Just after some advice on routes, this is the first time I've played
with them.

I had a site which used "http://www.example.com/rss.xml" at the root of
the site for the RSS feed. My new Rails powered site however uses
generated rss at "http://www.example.com/posts/feed". (That is, I have a
posts controller with the method 'feed' which falls through to an xml
template).

What is the best way for me to forward requests for the rss.xml file to
the new posts/feed controller method?

Can I do this with routes? If so, perhaps someone could nudge me in the
right direction.

Would this be better done with a redirect at the webserver?

Any advice is, as always much appreciated,

- N

Add this to routes and tell me if it works for you.

map.rss_feed “/rss.xml”, :controller => “posts”, :action => “feed”

Just make sure you put it above your other routes.

Thanks Brian,

I had tried this, but I got the error "Only get, head, post, put, and
delete requests are allowed.". After your suggestion I decided to really
make sure and restarted the server. Now it works :slight_smile:

Thanks for the prompt!

- N

Just an FYI - I’ve seen that happen a lot recently. Doing what you did seems to resolve it.