如何在子目录中部署 Rails 3.1 应用程序 [英] How to deploy Rails 3.1 app in a subdirectory
问题描述
如何将 Rails 3.1 应用程序配置为在/r"等特定目录下运行?
How do I configure a Rails 3.1 application to run under a specific directory such as "/r"?
我在 config.ru 中尝试过:
I tried in config.ru:
map '/r' do
run Debtor::Application
end
但刚刚返回未找到:/r"
but that just returned "Not Found: /r"
为了让它工作,我必须将所有路由都包含在一个范围内:
To get it to work I had to enclose all routes in a scope:
scope '/r' do
#routes
end
并将以下行添加到 config/applcation.rb
and to add the following line to config/applcation.rb
config.assets.prefix = "/r/assets"
并将我的 jquery ui css 文件从/stylesheets 移动到/r/stylesheets.
and to move my jquery ui css files from /stylesheets to /r/stylesheets.
这看起来太复杂了.没有更简单的方法吗?为什么我的 config.ru 设置不起作用?
this seems too complicated. isn't there an easier way? and why isn't my config.ru setting working?
我的用例是为 wordpress 服务器使用 Rails 驱动的 ajax 后端.
my use case is to have a rails powered ajax backend for a wordpress server.
推荐答案
您是否在乘客下奔跑?
那么 RailsBaseURI 可能就是你想要的.
Then RailsBaseURI is probably what you want.
https://www.phusionpassenger.com/library/deploy/apache/deploy/ruby/#deploying-an-app-to-a-sub-uri
如果不是在乘客下运行,请更新您的问题以显示您部署在什么下.
If not running under passenger, please update your question to show what you are deployed under.
这篇关于如何在子目录中部署 Rails 3.1 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!