bug in routes ???

Hi,

Is this a bug in routes, or something I’m doing wrong. Basically from what I can tell the url_for being generated in the case where my existing controller had a forward slash (i.e. active_rbac/login) may be causing a problem. I’m creating a link to a different controller however the URL created has a piece of the previous controller in it (i.e. active_rbac/). I put a breakpoint in the view and the run the following to confirm, see below. Also note the login aspects use a plugin.

Is this a bug?

============== debug / irb ========================= irb(#<#Class:0x39bea80:0x39bea50>):051:0* params => {“action”=>“login”, “controller”=>“active_rbac/login”, “locale”=>“en”}

irb(#<#Class:0x39bea80:0x39bea50>):052:0> session[:locale] => “en”

irb(#<#Class:0x39bea80:0x39bea50>):053:0> url_for => “/en/active_rbac/login/login”

irb(#<#Class:0x39bea80:0x39bea50>):054:0> url_for :locale => “fr” => “/fr/active_rbac/login”

irb(#<#Class:0x39bea80:0x39bea50>):055:0> url_for :locale => “fr”, :controller => “splash”

=> “/fr/active_rbac/splash” <== PROBLEM HERE, I expect to see “/fr/splash”

irb(#<#Class:0x39bea80:0x39bea50>):056:0>

Hi,

I’m still battling this one and am yet unsure whether this is a bug or not. It would be great if someone could put me out of my misery and confirm whether this is bug or not?

With the latest testing to characterise the problem it seems to be something to do with (a) controllers a sub-directory down &/or (b) url_for usage in a layout perhaps. That is in the sense that I have a " url_for" which resolves fine when the context is one controller but throws an error when in the context of another.

Key points include:

  1. routes.rb routes a URL to a controller which is down 1 subdirectory - Example map.connect ‘:locale/mygoodness’, :controller => ‘highlevel/midlevel’, :action => ‘testaction’, :defaults => {:locale => nil}

    map.connect ‘:locale/contactbackdoor’, :controller => “contacts”, :defaults => {:locale => nil}

  2. controller picks this up ok class Highlevel::MidlevelController < ApplicationController def testaction

    puts “Highlevel::MidlevelController - testaction” end

end

  1. the “views/highlevel/midlevel/testaction.rhtml” view is small as the

application.rb has a layout “site_layout” line.

  1. The “site_layout” has

        <%= link_to "2-contacts ", :controller => 'contacts' %>
    
  2. The site_layout link is generator OK when it is used from the opening page, BUT when it is utilised after a URL has come in via the controller which is down a sub-directory ( i.e. 'highlevel/midlevel) an error is encountered. See below.

  3. Note the hash indicated in the error below has ":controller=>" highlevel/contacts" and it has seemed to munge the “highlevel/midlevel” controller name with the “contacts” controller name.

  4. Interestingly if I change the “url_for” line in the layout to:

  • <%= link_to "2-contacts “, :controller => nil %> one sees the following in the error `:controller=>”

    highlevel/highlevel/midlevel"

    `

  • <%= link_to "2-contacts ", :controller => “” %> one sees the following in the error

    :controller=>"highlevel/"