What is the replacement for ActionController::Base.relative_url_root?

后端 未结 3 449
说谎
说谎 2020-11-28 08:35

I am porting a 2.x rails app to rails3; we\'ll call it foo-app. Foo-app is one section of a larger rails app and lives at main_rails_app.com/foo-app. Previously we just set

3条回答
  •  感情败类
    2020-11-28 09:36

    If you deploy via Passenger, use the RackBaseURI directive: http://www.modrails.com/documentation/Users%20guide%20Apache.html#RackBaseURI

    Otherwise, you can wrap the run statement in your config.ru with the following block:

    map ActionController::Base.config.relative_url_root || "/" do
      run FooApp::Application
    end
    

    Then you only have to set the environment variable RAILS_RELATIVE_URL_ROOT to "/foo-app". This will even apply to routes set in gems or plugins.

    Warning: do not mix these two solutions.

提交回复
热议问题