Bug colliding classes (when they shouldn't)
Reported by Eduard Gimenez | July 3rd, 2008 @ 04:06 PM | in 2.2
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.
Comments and changes to this ticket
-
Eduard Gimenez July 3rd, 2008 @ 04:10 PM
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.
-
Eduard Gimenez July 3rd, 2008 @ 04:42 PM
Seems it was broken in 2d372d704987e05712ccd937e78d8dbd41242efe
-
Dieter Komendera July 3rd, 2008 @ 06:14 PM
- no changes were found...
-
Dieter Komendera July 3rd, 2008 @ 06:14 PM
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.
-
Dieter Komendera July 3rd, 2008 @ 11:01 PM
- → Tag changed from 2.1 bug generators to 2.1 bug edge generators
- → Assigned user changed from to Joshua Peek
Indeed, with 2d372d704987e05712ccd937e78d8dbd41242efe reverted, everything works fine again.
What was the patch about?
-
Matthijs Langenberg July 9th, 2008 @ 02:17 PM
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?
-
Joshua Peek July 12th, 2008 @ 04:06 PM
- → State changed from new to resolved
-
-
-
wildchild August 9th, 2008 @ 01:26 PM
Experiencing the same problem
$ script/generate controller hello::world => OK! $ script/generate controller hello::everyone => The name 'hello' is either already used in your...
-
Bryan T. Richardson August 23rd, 2008 @ 10:13 PM
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...
-
Claudio Poli August 23rd, 2008 @ 10:17 PM
problem arises when including helper :all in ApplicationController for me.
-
Major Kong August 25th, 2008 @ 09:59 PM
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)
-
Alexandre da Silva September 17th, 2008 @ 07:59 PM
- → 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.
-

lakshan (at web2media) October 7th, 2008 @ 05:22 AM
I'm also running the latest edge release but still experience this collision. Any idea what's happening?
-
Matthijs Langenberg October 7th, 2008 @ 08:20 AM
- no changes were found...
-
Major Kong October 7th, 2008 @ 10:44 AM
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.
-
Claudio Poli October 8th, 2008 @ 03:48 PM
- → Tag changed from "2.1" bug edge generators to 2.1 bug bug edge generators
definitely not solved on edge.
again, the problem appears when including
helper :all
in ApplicationController.
-

claytonlz October 11th, 2008 @ 09:07 PM
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
-
Joshua Peek October 12th, 2008 @ 06:58 PM
- → Tag changed from 2.1 bug bug edge generators to generators
- → Milestone changed from 2.x to 2.2
- → State changed from resolved to open
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.
-
-

Repository October 14th, 2008 @ 03:45 AM
- → 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...
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Source available from github
Repository is at http://github.com/rails/rails
Check out the development master (Edge Rails):
git clone git://github.com/rails/rails.git
Creating or reviewing a patch
See the contributor guide.
Creating a feature request
Please don't. If you want a new feature in Rails, you'll have to pull up your sleeves and get busy yourself. Or convince someone else to do it. See the contributor guide on how to get going. But posting them here is just going to lead to ticket root.
Creating a bug report
When creating a bug report, be sure to include as much relevant information as possible. Post the code sample that causes the problem. Preferably, alter the unit tests and show through either changed or added tests how the expected behavior is not occuring.
Security vulnerabilities should be reported via an email to security@rubyonrails.org, do not use trac for reporting security vulnerabilities. All content in trac is publicly available as soon as it is posted.
Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kinda bug, you're creating this ticket in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the ticket automatically will see any activity or that others will jump to fix it. Creating a ticket like this is mostly to help yourself start on the path of fixing the problem and for others to sign on to with a "I'm having this problem too"..
