开发者

Rails/Passenger sub URI error

开发者 https://www.devze.com 2023-01-13 18:15 出处:网络
I am attempting to deploy a Rails 3.0.0 application to a sub URI using passenger 2.2.15. I believe I\'ve made the correct RailsBaseURI changes to my http.conf , have symlinked the sub URI to the publ

I am attempting to deploy a Rails 3.0.0 application to a sub URI using passenger 2.2.15.

I believe I've made the correct RailsBaseURI changes to my http.conf , have symlinked the sub URI to the public directory of my app and added the following line of code to environments/production.rb:

config.action_controller.relative_url_root = "/sub_uri"

I've done this several times pre-rails3.0.0. That said, the app won't launch. It fails with the following Passenger error:

Error Message: wrong number of arguments(1 for 0)

Exception class: ArgumentError

/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.0/lib/action_controller/railtie.rb 54 in `relative_url_root='

Is there an incompatibility between passenger 2.2.15 and rails开发者_运维百科 3.0.0 that affects sub URI's?

Any help sorting out this error is greatly appreciated.


The setter is depreciated, it's nowhere to be found in actionpack/lib/action_controller/railtie.rb.

As seen here (actionpack/lib/action_controller/depreciated/base.rb):

module ActionController
  class Base
    # Deprecated methods. Wrap them in a module so they can be overwritten by plugins
    # (like the verify method.)
    module DeprecatedBehavior #:nodoc:
      def relative_url_root
        ActiveSupport::Deprecation.warn "ActionController::Base.relative_url_root is ineffective. " <<
          "Please stop using it.", caller
      end

      def relative_url_root=
        ActiveSupport::Deprecation.warn "ActionController::Base.relative_url_root= is ineffective. " <<
          "Please stop using it.", caller
      end
    end
  end
end

In actionpack/lib/action_controller/metal/compatibility.rb you can see it's setter is an ENV variable:

self.config.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']

So you need to set the ENV variable: RAILS_RELATIVE_URL_ROOT="/sub_uri"


To set the environment variable add:

SetEnv RAILS_RELATIVE_URL_ROOT /sub_uri

To the VirtualHost section (or similar) of your apache config then make sure it's being read by restarting apache and passenger.

cd <your_rails_project>
sudo apache2ctl graceful
touch tmp/restart
0

精彩评论

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