使用虚拟文件夹名称作为所有 URL 的前缀

发布于 2024-10-06 03:58:40 字数 443 浏览 0 评论 0原文

我正在尝试在 Passenger 不支持的服务器上部署我的 RoR 3.0 应用程序。一切都工作正常,直到我决定为我的应用程序服务器使用 Apache 虚拟文件夹。在生产环境中,我现在必须在所有 URL 前面手动添加文件夹名称,例如使用 :host =>所有 url_for 调用中的“myServer/myApp”。它有效,但很痛苦。有人知道自动化的好方法吗?    

在阅读了许多帖子后,到目前为止,我尝试过但没有成功:

  • define default_url_for { :host => "myServer/myApp" } 在 application.rb 中,但没有效果

  • 我发现了一些定义 url_for 并从其中调用 super 的指示。也没有效果

谢谢你的帮助

Hadrien

I'm trying to deploy my RoR 3.0 application on a server that is not supported by Passenger. Everything worked fine until I decided to use an Apache virtual folder for my application server. On the production environment I now have to manually add the folder name in front of all URL, for instance using a :host => "myServer/myApp" in all url_for calls. It works but it is painful. Does anybody know a nice way to automate it?    

Here what I tried unsuccessfully so far after reading many posts:

  • define default_url_for { :host => "myServer/myApp" } in application.rb, but had no effect

  • I found some indication to define url_for and call super from inside it. No effect either

Thanks for your help

Hadrien

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

渔村楼浪 2024-10-13 03:58:40

快速但肮脏的解决方案是将所有内容包装在 config/routes.rb 文件中的 scope 块内:

scope 'myApp' do  # replace 'myApp' with the virtual folder name

  resources :users
  # ...

end

The quick and dirty solution is to wrap everything inside a scope block in your config/routes.rb file:

scope 'myApp' do  # replace 'myApp' with the virtual folder name

  resources :users
  # ...

end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文