ruby-on-rails – 如果定义了如何编写使用relative_url_root的重
发布时间:2020-12-17 03:22:28 所属栏目:百科 来源:网络整理
导读:我目前正在使用 Ruby on Rails 3.2.8并在config / routes.rb中进行此重定向: root :to = redirect("/home/index.html") 适用于在开发中将http:// localhost:3000 /重定向到http:// localhost:3000 / home / index.html.但是在我的测试环境中,我正在使用
我目前正在使用
Ruby on Rails 3.2.8并在config / routes.rb中进行此重定向:
root :to => redirect("/home/index.html") 适用于在开发中将http:// localhost:3000 /重定向到http:// localhost:3000 / home / index.html.但是在我的测试环境中,我正在使用代理和子路径,在config / environments / test.rb中设置relative_url_root,如下所示: config.action_controller.relative_url_root = '/testpath' 所以我希望从http://testdomain.com/testpath重定向到http://testdomain.com/testpath/home/index.html,而是重定向到http://testdomain.com/home/index.html . 如果设置了,我如何更改我的重定向语句以使用relative_url_root? 解决方法
我不认为该方法已被弃用,但它是
does seem to be broken.您应该可以使用以下方法解决此问题:
root :to => redirect("#{ Rails.application.config.action_controller.relative_url_root }/home/index.html") 可能值得指出的是,这个bug在我的机器上是不可重现的(我使用的是瘦),你提出的代码按预期工作. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |