Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Navigation URLs aren't generated correctly when using Passenger's RackBaseURI #101

joevandyk opened this Issue · 64 comments

I have the Rails 3 application containing active_admin mounted as a suburi (i.e.

The links in ActiveAdmin below the navigation header work properly (

But the links in the header navigation section don't include the suburi. They look like


We definitely hit this too; I put in a quick fix that solved it for us, but the URL generation here is pretty gross.



would using logout_path not work? (or whatever it's called)


I've also hit this problem when mounting the app under a sub-directory on Heroku using Rack::Builder#map

map "/sub-uri" do
  run My::Application

All the links below the header work fine, but the tab links do not include the sub-directory as described above.

The quick fix mentioned by @andrewcarpenter will not work in Rails 3 since relative_root_url is deprecated.

This is the same issue as #280


Is this issue happening with 0.3.0?


I've just updated to 0.3.2 and this is still broken in my app. Has an explicit commit been made to fix this or are you just checking to see if it's still an open issue?


I'm also still getting this.


Tested on 0.3.3, same issue occurring.

Have an app that is deployed in a sub-ur ( via mod_passenger's RailsBaseURI.
Top-most menu with links to dashboard, models, etc generates links without proper sub-uri
E.g. dashboard point to instead of


I meet the same issue as 0.3.4 is used. The result displayed in #header is really bad. How can we fix it?


Also having this issue


me too

as 0.3.4


same issue but we're using nginx + unicorn for production.


+2 (I have two apps) with nginx + passenger

@gregbell gregbell closed this issue from a commit
@gregbell gregbell Moved the resolving of menu items into the view.
Doing this ensures that the full Rails router has been loaded including
any scoping and RackBaseURI configurations.

Fixes #101, #960
@gregbell gregbell closed this in 3e7ac40
@gregbell gregbell was assigned

Thank you, sir!


I'm using v 0.6.0 and having the same issue. This problem returns?


@josecoelho can you provide some more detail of what you're running into?


I have deployed on a suburl via mod_passenger's RailsBaseURI.


All other links of my application, are using the correct route to suburl. But tabbed menu links have the route to the root.

I found this commit b506c2e that removes the fix made on commit that fixes this issue.

I need to configure someting else to made this work? Thanks a lot


Any idea on @josecoelho issue? Same problem here!


@josecoelho so it's only nested menu items whose URLs aren't in the /myapp/ namespace?


No. The problem is on all superior menu items, nested or not.


What do you mean by "superior" menu items?


Sorry about my english. :)

All top menu itens have the route problem on suburls.
screen shot 2013-05-20 at 11 29 37 am

It was fixed on 3e7ac40 but the fix was undone on b506c2e

Some examples of menu item definition:

ActiveAdmin.register AdminUser do
    menu :label => "Usuários"
    menu :parent => "Cadastros"

ActiveAdmin.register Client do
    menu :label => "Pessoas"

I'm still not sure what you mean. Could you provide examples of what the URLs should be, and what they are?

By top / superior menu items do you mean the parent?

menu parent: 'Cadastros'

So Cadastros would be a parent menu item, with nested / children menu items below it.


Sorry about that...

On an application configured to run via mod_passenger's with RailsBaseURI as /myapp

This code:

    ActiveAdmin.register Client do
       menu :label => "Pessoas"

Should result on a top menu item:

<a href="/myapp/admin/clients">Pessoas</a>

But, is ignoring RailsBaseURI configuration and rendering this:

<a href="/admin/clients">Pessoas</a>

The same problem occur with menu itens having parents.


Thanks for the added detail.

Can you see if 9b44a50 works for you? It's the commit immediately before b506c2e.

Also, instead of RailsBaseURI have you tried using RackBaseURI?


Hi Daxter,

Before test 9b44a50 I've changed from RailsBaseURI to RackBaseURI with no success.

Using 9b44a50 doesn't work too. Oo

I try to use 3e7ac40 but its too old and have incompatibilities.


Since 9b44a50 doesn't work either, then that means this problem wasn't caused by b506c2e.

Earlier you said that you're running into this problem on 0.6.0; does 0.5.1 work correctly?




Although I'm not using Passenger but Unicorn + Nginx, but facing the same problem. What finally worked for me (probably not the best approach, but I was going insane) was:

  • Run the rails server with the variable ENV['RAILS_RELATIVE_URL_ROOT'] (in my case, on the .env file because I'm using Foreman)

  • Scope all my routes (including ActiveAdmin mount) with:

    MyApp::Application.routes.draw do
      scope ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
        # All my routes
  • Not using any map in my file (which I tried before but ActiveAdmin was still facing the problem).

0.5.1 work correctly, problem on 0.6


I've defined my subUri like so

config.action_controller.relative_url_root = '/app'

Since Version 0.6, the subUri is ignored, but only in the submenu entries. All other links are o.k, the logout link as well. (See #1173)


Is there a solution for this in 0.6? We are stuck in the water on this one. We use RackBaseURI to partition our Apache server into several web apps. When we use AA, the menu items ignore the base and therefore generate the wrong URL so navigation is broken.

@seanlinsley seanlinsley reopened this

@edwja I'm not sure what's even causing the problem, so it's hard to tell what the solution is :/

Re-opening since I didn't do that earlier.


I'm guessing it is in the bits that create the href urls in the "tabs" id of the header-items inside the header div. Those seem to be the malformed urls. I am new to AA, so I am not able to find the code that builds those urls, but it looks like the base is coded as /admin rather that base_url + /admin.

Thanks for looking. :)


Struggled with this myself heres a workaround:

ActiveAdmin.register Client do
menu :url => "app/admin/client"

not sure how it will effect submenus however.


It turns out that this is a bug in Rails 3 related to how the url builder uses the :script_name attribute for the default_url_options. My workaround is to have the following in application.rb:

Rails.application.routes.default_url_options[:script_name] = ActionController::Base.config.relative_url_root || '/'

I also have passenger.conf set with a SetEnv line in the Directory stanza for the sub-site:


and everything works as expected.


Since this setting is no longer supported by Rails, I'm going to close this ticket.


I am using 0.6.1 and Rails 4 and still running into this issue.

Is this still a problem for others? What is the correct resolution?

Is activeadmin unusable if the application is not installed in the server's root?


Using the Rails method, it works perfectly:

scope '/foo' do
  devise_for :admin_users, ActiveAdmin::Devise.config

Not quite perfectly for me, unfortunately. When I do this, I can no longer get to the admin page (or any other part of my app). When I go to:, I get:

No route matches [GET] "/admin"
Rails.root: /data/sites/devapps/foo

In "rake routes", all of my routes now have "/foo" prepended onto them, even though "/foo" is part of my base path. This doesn't seem right. I am running several apps on this port, and anything not at /foo should not hit this app.

Please note that my apache/passenger config looks like this:

<VirtualHost *:80>
    ServerAlias devapps
    DocumentRoot /data/sites/devapps/public
    CustomLog /data/site-logs/devapps/access_log usertrack
    ErrorLog /data/site-logs/devapps/error_log
    RewriteEngine on
    <Directory /data/sites/devapps/public>
       Allow from all

    RailsEnv development
    RackBaseURI /foo
    <Directory /data/sites/devapps/public/foo>
        Options -MultiViews
    RackBaseURI /bar
    <Directory /data/sites/devapps/public/bar>
        Options -MultiViews

The only thing I could think to try is to change RackBaseURI to "/", but this means it cannot find my, so I assume this isn't correct.

Would you have any further advice on how to do this? Before making any changes, all of my other routes and path helpers seemed to be working, correctly including the "/foo". (Including the admin routes.) The only problem seems to be with the header menus in activeadmin, which seem to be ignoring the base path, even though the helpers return it correctly.

I could be missing something, but this seems to be exactly what others have been describing. Is it that activeadmin does not support being in a Rails app not installed at the URL domain root path?


@seanlinsley seanlinsley reopened this

+1, I have exactly the same problem ... Rails 4 and ActiveAdmin 0.6.1


+1, Same here ... ActiveAdmin 0.6.1 and Rails 4 and Rails 4.0.1.rc1


+1, Same here with rails 4, passenger.

It seems that only links to model/resource are wrong. At model index, the filter and actions links are OK, but links to associations are broken too. Menu links on the left, dashboard and models, are broken. Links at right side are ok ( current user and logout).


I may be wrong, but it seems that urls from here, are fine

  • lib/active_admin/namespace.rb: :url => proc{ url_for [, current_active_admin_user] rescue '#' },

But urls generated here ignore relative_url_root:

  • lib/active_admin/resource/menu.rb: :url => proc{ resource.route_collection_path(params) },

Did you try the workaround I posted earlier? For Rails 3.2, it has been working well for me with active_admin. HTH


What needs to be done to resolve this?


Setting Rails.application.routes.default_url_options[:script_name] to the relative URL root path works everywhere except the redirect that occurs after logout. Problem appears to be that in this case the code is using Rails.configuration.action_controller[:relative_url_root], which is picked up from the Passenger config as it should be, in addition to the "script_name" value.



I can't get this to work with the solution mentioned by @danders0n - I have AA 0.6.1, and Rails 4.1, Ruby 2.1.

I did this in my config\application.rb inside the application's module:

Rails.application.routes.default_url_options[:script_name] = ActionController::Base.config.relative_url_root || '/'

and also tried setting config.relative_url_root in environments\production.rb but couldn't get the navigation URLs on my Passenger-based deployment to use the URI with the sub-path that is configured in Passenger/Apache.


@siruguri how are you using AA 0.6.1 with Rails 4.1? The 0.6.x line doesn't support Rails 4 at all.


Nrgh. My bad. I hadn't installed Polyamorous and Ransack in my Gemfile. It works after I did that. I am not sure how that mattered and why AA was working without those gems. Or it might have been some weird gem update problem - I kept getting a 0.6.1 when I did gem which but the bundle install was done pointing to master on your repo. Might have been an artefact of some config combo on my laptop.

Rails.application.routes.default_url_options[:script_name] = '/my_app' 

worked for me. 1.0.0 pre with Rails 4.1.1

Rails.application.routes.default_url_options[:script_name] = '/my_app' 

Works for me too, but a redirect occurs at login and logout!


+1 for Rails.application.routes.default_url_options[:script_name] = '/my_app' -- Still need to get assets working from ActiveAdmin though. Did assets (such as chosen-sprite and datepicker) work for you @harinisaladi, @kuboon, or @siruguri?

@orenyk orenyk referenced this issue in YaleSTC/reservations

Active Admin navbar links broken #964


Any news on this, just ran into it, internal nav links ignore my passenger base URI and cause a 404 unless I manually add /server/ before admin.


@Patsy-issa Have you tried this code? #101 (comment)


@kuboon Just added it in now, works like a charm, avoided it in the first place when I read that it broke assets. Cheers.

@timoschilling timoschilling added Routing and removed Routing labels

Can someone confirm that relative_url_root works in a normal Rails App?
I have tried to set relative_url_root = "/myapp", but in a Rails scaffold all url's a not respecting relative_url_root.
I think this is not a ActiveAdmin bug, it looks like a Rails bug.


Now I get a bit deeper into relative_url_root, it's deprecated and works now only for configuring rake asset:precompile. See rails/rails#2435 (comment) for details and workaround.


Encountered this problem with AA 0.6.0 and Rails 3.2.

This fix:
#101 (comment)

correctly resolved the issue fo rme.


@armahillo 's solution worked for me. Actually, all I needed was the 1st part--didn't need to use SetEnv RAILS_RELATIVE_URL_ROOT=/foo. Rails 4.1.9 and activeadmin from github, commit 95127af


The only solution that worked for me with Rails 4.2 and AA from github is to manually set the menu urls like mentioned here #101 (comment)


yeah, not the best solution but also fixed the issue for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.