I'm stuck on a Rails 2.3 app trying to redirect some old URLs. I'm new to RoR and know 3+ way better, so I'm having trouble getting this done.
So: http://siteurl.com/foo/:foo_id goes to http://siteurl.com/foo/:foo_id/foo_items
I think I'm close because the end product goes to: http://siteurl.com/foo/foo_id/foo_items but doesn't pass the :foo_id
params it actually writes it out!
Any help, or pointers are much appreciated.
In my routes.rb
map.connect '/foo/:foo_id',
:controller => 'redirect',
:action => :redirectoldfoo,
:monkey_tag => ':foo_id'
In my redirect controller:
def redirectoldfoo
redirect_to "/auctions/#{params[:monkey_tag]}/catalog_items"
end
You should not need the :monkey_tag
at all, since :foo_id
is all you're using anyway.
map.connect '/foo/:foo_id',
:controller => 'redirect',
:action => :redirectoldfoo
def redirectoldfoo
redirect_to "/auctions/#{params[:foo_id]}/catalog_items"
end
Note that in your example you indicated that you were trying to redirect to both /foo/:foo_id/foo_items
and then /auctions/:foo_id/catalog_items
. I assumed that the second one was closer to the real code, so I left that one in there.