Rails app in a subdirectory

前端 未结 2 917
野趣味
野趣味 2020-12-03 11:17

Trying to set up a Rails app in a subdirectory. My server is Cherokee. I have a base url of: www.nonsense.com, which is a wordpress blog, and I wish to set up a rails app i

相关标签:
2条回答
  • 2020-12-03 11:48

    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 讨论(0)
  • 2020-12-03 12:05

    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

    0 讨论(0)
提交回复
热议问题