rails: config.action_controller.relative_url_root doesn't work in Rails 3.1

According to documentation, there is a configuration option config.action_controller.relative_url_root: http://guides.rubyonrails.org/configuring.html#configuring-action-controller

But when I set config.action_controller.relative_url_root, I get:

<NoMethodError: undefined method `relative_url_root=' for ActionController::Base:Class>
org/jruby/RubyKernel.java:2097:in `send'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/actionpack-3.1.3/lib/action_controller/railtie.rb:37:in `Railtie'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/ordered_hash.rb:162:in `each'
org/jruby/RubyArray.java:1612:in `each'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/ordered_hash.rb:162:in `each'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/actionpack-3.1.3/lib/action_controller/railtie.rb:37:in `Railtie'
org/jruby/RubyKernel.java:2062:in `instance_eval'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:43:in `run_load_hooks'
org/jruby/RubyArray.java:1612:in `each'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/activesupport-3.1.3/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/actionpack-3.1.3/lib/action_controller/base.rb:234:in `Base'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/actionpack-3.1.3/lib/action_controller/base.rb:171:in `ActionController'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/actionpack-3.1.3/lib/action_controller/base.rb:3:in `(root)'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/actionpack-3.1.3/lib/action_controller/base.rb:31:in `ext'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/actionpack-3.1.3/lib/action_dispatch/middleware/static.rb:15:in `match?'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/actionpack-3.1.3/lib/action_dispatch/middleware/static.rb:47:in `call'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/engine.rb:456:in `call'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/rack-1.3.6/lib/rack/content_length.rb:14:in `call'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/railties-3.1.3/lib/rails/rack/log_tailer.rb:14:in `call'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/rack-1.3.6/lib/rack/handler/mongrel.rb:77:in `process'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:159:in `process_client'
org/jruby/RubyArray.java:1612:in `each'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:158:in `process_client'
C:/java/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/mongrel-1.1.5-java/lib/mongrel.rb:285:in `run'
org/jruby/RubyProc.java:270:in `call'
org/jruby/RubyProc.java:224:in `call'

About this issue

  • Original URL
  • State: closed
  • Created 12 years ago
  • Comments: 19 (12 by maintainers)

Commits related to this issue

Most upvoted comments

I’m very confused as to the recommended way to mount a rails app in a sub-directory.

What I’ve had success with is setting both the MyApp::Application.config.relative_url_root in application.rb and wrapping the run App command in config.ru:

map MyApp::Application.config.relative_url_root || "/" do
  run Rails.application
end

However, it does not work in test, the sub-directory is not utilized, perhaps because config.ru is not used by minitest / rspec when loading the rails environment? When Devise redirects to the sign in page, I get a RouteError because route /path-to/users/sign-in does not work (this suggests Devise does use the sub-directory somehow but the rest of the Rails env doesn’t…).

I’ve tried the alternative of wrapping the routes in a scope and while it appears to work in dev, I cannot make the assets to load.

A definitive guide would be most welcome.