开发者

Rails app in a subdirectory

Trying to set up a Rails app in a subdirectory. My server is Cherokee. I have a ba开发者_如何学Pythonse url of: www.nonsense.com, which is a wordpress blog, and I wish to set up a rails app in, www.nonsense.com/rails_app.

A quick scan of google led me to using: ActionController::AbstractRequest.relative_url_root = "/rails_app"

However, it seems this has been removed in the latest Rails. Any ideas as to the equivalent in Rails 2.3.8?


For Rails 4/5, you can set this in application.rb or production.rb:

config.relative_url_root = "/app1"

Or simply set this environment variable:

RAILS_RELATIVE_URL_ROOT='/app1'

However, I've found that this only prefixes paths to assets. URL paths created by url helpers doesn't respect this setting.

Turns out, there's a bug related to this: https://github.com/rails/rails/issues/5122

This is supposed to have fixed it, but I've not found that to be the case: https://github.com/rails/rails/pull/18775/files

The documentation for this feature isn't very clear on how exactly it's supposed to work:

http://edgeguides.rubyonrails.org/configuring.html#deploy-to-a-subdirectory-relative-url-root

Maybe try namespacing instead:
http://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing

This answer might also be helpful:
Configuring a Rails 4 app for production in a subdirectory under Apache


you want to use this in your environment file now:

config.action_controller.relative_url_root = '/rails_app'

Source: http://edgeguides.rubyonrails.org/configuring.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜