This project is archived and is in readonly mode.

#3376 ✓stale
Pawel Barcik

Routing map.namespace function definition bug

Reported by Pawel Barcik | October 14th, 2009 @ 05:21 PM

file actionpack-2.3.4/lib/action_controller/routing/route_set.rb

47 def namespace(name, options = {}, &block) 48 if options[:namespace] 49 with_options({:path_prefix => "#{options.delete(:path_prefix)}/#{name}", :name_prefix => "#{options.delete(:name_prefix)}#{name}", :namespace => "#{options.delete(:namespace )}#{name}/" }.merge(options), &block) 50 else 51 with_options({:path_prefix => name, :name_prefix => "#{name}", :namespace => "#{name}/" }.merge(options), &block) 52 end 53 end

does line 49 in this file not suppose to be

49 with_options({:path_prefix => "#{options.delete(:path_prefix)}/#{name}", :name_prefix => "#{options.delete(:name_prefix)}#{name}_", :namespace => "#{options.delete(:namespace )}/" }.merge(options), &block)

with #{name} deleted ?

because this route is causing problems when used with this route:

map.namespace :panel, :namespace => 'admin_panel' do |admin_panel|

admin_panel.root  :controller => 'panel'
admin_panel.connect ':controller/:action/:id'

end

error:

uninitialized constant AdminPanelpanel

/usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:443:in load_missing_constant' /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:inconst_missing_with_dependencies' /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:92:in const_missing' /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/inflector.rb:372:inconst_get' /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/inflector.rb:372:in block in constantize' /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/inflector.rb:371:ineach' /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/inflector.rb:371:in constantize' /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/core_ext/string/inflections.rb:162:inconstantize' /usr/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:443:in recognize' /usr/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:436:incall'

the route used:

mydomain.com/panel/

Comments and changes to this ticket

  • Pawel Barcik

    Pawel Barcik October 14th, 2009 @ 05:28 PM

    (better formated copy of the post)

    file actionpack-2.3.4/lib/action_controller/routing/route_set.rb

     47 def namespace(name, options = {}, &block)
     48           if options[:namespace]
     49             with_options({:path_prefix => "#{options.delete(:path_prefix)}/#{name}", :name_prefix => "#{options.delete(:name_prefix)}#{name}", :namespace => "#{options.delete(:namespace    )}#{name}/" }.merge(options), &block)
     50           else
     51             with_options({:path_prefix => name, :name_prefix => "#{name}", :namespace => "#{name}/" }.merge(options), &block)
     52           end
     53         end
    
    does line 49 in this file not suppose to be
    49             with_options({:path_prefix => "#{options.delete(:path_prefix)}/#{name}", :name_prefix => "#{options.delete(:name_prefix)}#{name}_", :namespace => "#{options.delete(:namespace    )}/" }.merge(options), &block)
    
    with #{name} deleted ?

    because this route is causing problems when used with this route:

      map.namespace :panel, :namespace => 'admin_panel' do |admin_panel|

    admin_panel.root  :controller => 'panel'
    admin_panel.connect ':controller/:action/:id'
    
    
    
    
    end
    error:
    uninitialized constant AdminPanelpanel
    
    /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:443:in `load_missing_constant'
    /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:80:in `const_missing_with_dependencies'
    /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:92:in `const_missing'
    /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/inflector.rb:372:in `const_get'
    /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/inflector.rb:372:in `block in constantize'
    /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/inflector.rb:371:in `each'
    /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/inflector.rb:371:in `constantize'
    /usr/local/lib/ruby1.9/gems/1.9.1/gems/activesupport-2.3.4/lib/active_support/core_ext/string/inflections.rb:162:in `constantize'
    /usr/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:443:in `recognize'
    /usr/local/lib/ruby1.9/gems/1.9.1/gems/actionpack-2.3.4/lib/action_controller/routing/route_set.rb:436:in `call'
    

    the route used:

    mydomain.com/panel/

  • Rohit Arondekar

    Rohit Arondekar October 6th, 2010 @ 06:34 AM

    • State changed from “new” to “stale”
    • Importance changed from “” to “”

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

  • csnk

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages