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.

Bug colliding classes (when they shouldn't)

#545

Creating two classes, controllers, with the same name but in different namespaces (i.e. Post and Admin::Post) fails.


$ rails -v
Rails 2.1.0
$ ruby -v
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]

$ rails test
$ cd test/
$ script/generate scaffold Posts title:string body:text
$ script/generate controller -t Admin::Posts
The name 'Admin::PostsHelper' is either already used in your application or reserved by Ruby on Rails.
  Please choose an alternative and run this generator again.
  /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/rails_generator/commands.rb:392:in `raise_class_collision'
  /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/rails_generator/commands.rb:185:in `class_collisions'
  /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/rails_generator/manifest.rb:47:in `send'
  /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/rails_generator/manifest.rb:47:in `send_actions'
  /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/rails_generator/manifest.rb:46:in `each'
  /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/rails_generator/manifest.rb:46:in `send_actions'
  /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/rails_generator/manifest.rb:31:in `replay'
  /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/rails_generator/commands.rb:42:in `invoke!'
  /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/rails_generator/scripts/../scripts.rb:31:in `run'
  /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/commands/generate.rb:6
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require'
  script/generate:3

I can reproduce this behavior in the console, but not in the rails tests.

Reported by Eduard Gimenez · July 3rd, 2008 @ 04:06 PM

State: resolved
Milestone: none
Assigned to: josh josh
Importance: none

Activity

  1. Eduard Gimenez
    Eduard Gimenez

    Also, calling controller generator the two times also fails.

    $ rails test2

    $ cd test2

    $ script/generate controller Post

    $ script/generate controller Admin::Post

    The name 'Admin::PostHelper' is either already used in your application or reserved by Ruby on Rails.

    Please choose an alternative and run this generator again.

    July 3rd, 2008 @ 04:10 PM

  2. Eduard Gimenez
    Eduard Gimenez

    Seems it was broken in 2d372d704987e05712ccd937e78d8dbd41242efe

    July 3rd, 2008 @ 04:42 PM

  3. Dieter Komendera
  4. Dieter Komendera
    Dieter Komendera

    I can confirm this bug. I'll attach a quick test case which shows the problem. This test case fails with 2.1 and latest version from github.

    July 3rd, 2008 @ 06:14 PM

  5. Dieter Komendera
    Dieter Komendera
    • Tag changed from 2.1, bug, generators to 2.1, bug, edge, generators
    • Assigned user set to josh

    Indeed, with 2d372d704987e05712ccd937e78d8dbd41242efe reverted, everything works fine again.

    What was the patch about?

    July 3rd, 2008 @ 11:01 PM

  6. Matthijs Langenberg
    Matthijs Langenberg

    I've also ran into this with Rails 2.1.0.

    mlangenberg-mbp:test-app mlangenberg$ script/generate controller adminblabla/post
      The name 'Adminblabla::PostHelper' is either already used in your application or reserved by Ruby on Rails.
      Please choose an alternative and run this generator again.
    

    Is this already fixed in the current HEAD?

    July 9th, 2008 @ 02:17 PM

  7. josh
    josh
    • State changed from new to resolved

    July 12th, 2008 @ 04:06 PM

  8. Claudio Poli
  9. Jose Fernandez
    Jose Fernandez

    Bug still shows up on my end, edge rails up to date.

    July 28th, 2008 @ 12:51 AM

  10. wildchild
    wildchild

    Experiencing the same problem

    $ script/generate controller hello::world => OK! $ script/generate controller hello::everyone => The name 'hello' is either already used in your...

    August 9th, 2008 @ 01:26 PM

  11. Bryan T. Richardson
    Bryan T. Richardson

    I'm getting the same as wildchild.

    $ script/generate controller World --> works $ script/generate controller Hello::World --> now works $ script/generate controller Hello::Universe --> The name 'hello' is either already used...

    August 23rd, 2008 @ 10:13 PM

  12. Claudio Poli
    Claudio Poli

    problem arises when including helper :all in ApplicationController for me.

    August 23rd, 2008 @ 10:17 PM

  13. Major Kong
    Major Kong

    I have tried to augment an existing controller with the scaffold generator and get the same error.

    rails foo cd foo script/generate scaffold fum script/generate scaffold fum title:string

    BOOM...

    "The name 'FumsHelper' is either already used in your application or reserved by Ruby on Rails. Please choose an alternative and run this generator again."

    gem list says: rails (2.1.0, 1.2.6)

    August 25th, 2008 @ 09:59 PM

  14. Alexandre da Silva
    Alexandre da Silva
    • Tag changed from 2.1, bug, edge, generators to 2.1, bug, edge, generators

    in 2.1.1 seems to be already there:

    $ ruby -v ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]

    $ rails -v Rails 2.1.1

    $ rails test $ cd test

    $ script/generate controller Posts ... $ script/generate controller Admin::Posts The name 'Admin::PostsHelper' is either already used in your application or reserved by Ruby on Rails. Please choose an alternative and run this generator again.

    September 17th, 2008 @ 07:59 PM

  15. Lakshan Perera
    Lakshan Perera

    I'm also running the latest edge release but still experience this collision. Any idea what's happening?

    October 7th, 2008 @ 05:22 AM

  16. Matthijs Langenberg
  17. Major Kong
    Major Kong

    Is there a way to see what changes were made to the source when the bug was flipped to "resolved"? It would be helpful to read the source in order to try to fix this since it, at least in my opinion, is not fully done.

    Or, perhaps this is by design; could someone then please explain to me what the rationale is.

    October 7th, 2008 @ 10:44 AM

  18. Claudio Poli
    Claudio Poli
    • Tag changed from 2.1, bug, edge, generators to 2.1, bug, edge, generators

    definitely not solved on edge.

    again, the problem appears when including

    helper :all
    

    in ApplicationController.

    October 8th, 2008 @ 03:48 PM

  19. claytonlz
    claytonlz

    With "helper :all" in application.rb

    $ rails -v Rails 2.1.1

    $ ruby -v ruby 1.8.6 (2007-09-23 patchlevel 110) [i686-darwin9.1.0]

    $ script/generate rspec_controller 'admin/categories'

    The name 'Admin::CategoriesHelper' is either already used in your application or reserved by Ruby on Rails. Please choose an alternative and run this generator again.

    Without "helper :all" in application.rb

    $ script/generate rspec_controller 'admin/categories' ... success

    October 11th, 2008 @ 09:07 PM

  20. josh
    josh
    • State changed from resolved to open
    • Milestone cleared.
    • Tag changed from 2.1, bug, edge, generators to generators

    I did revert the commit as suggested and applied that failing test.

    http://github.com/rails/rails/co...

    Apparently, the issue still exists. Any more patches :)

    This ticket is holding off the 2.2 beta release.

    October 12th, 2008 @ 06:58 PM

  21. josh
    josh

    Related:

    #138 - applied then reverted

    #1059 - another report of the issued (duplicate)

    October 12th, 2008 @ 07:00 PM

  22. Repository
    Repository
    • State changed from open to resolved

    (from [9ab83b1cd1323e0ffebbd287c38aff614c18822c]) Don't include the path when checking class collisions [#545 state:resolved] http://github.com/rails/rails/co...

    October 14th, 2008 @ 03:45 AM