Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Routing map.namespace function definition bug

#3376

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/

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

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Pawel Barcik
    Pawel Barcik

    (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/

    October 14th, 2009 @ 05:28 PM

  2. Rohit Arondekar
    Rohit Arondekar
    • 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.

    October 6th, 2010 @ 06:34 AM