I'm currently using Ruby on Rails 3.2.8 and have this redirect in config/routes.rb:
root :to => redirect("/home/index.html")
which works fine for redirecting http://localhost:3000/ to http://localhost:3000/home/index.html in development. But in my test environment, I'm using a proxy and a subpath, setting relative_url_root in config/environments/test.rb like this:
config.action_controller.relative_url_root = '/testpath'
So I would expect a redirect from http://testdomain.com/testpath to http://testdomain.com/testpath/home/index.html but instead it redirects to http://testdomain.com/home/index.html.
How can I change my redirect statement to use relative_url_root in case it is set?
I don't think that the method is deprecated, but it does seem to be broken. You should be able to work around the issue with something like this:
root :to => redirect("#{ Rails.application.config.action_controller.relative_url_root }/home/index.html")
It might be worth pointing out that this bug is not reproducible on my machine (I am using thin), the code you posed works as intended.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With