Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails/Passenger sub URI error

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.

like image 775
rswolff Avatar asked Feb 11 '26 07:02

rswolff


1 Answers

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"

like image 86
Garrett Avatar answered Feb 15 '26 17:02

Garrett



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!