This project is archived and is in readonly mode.
script/generate glitch for controllers in modules
Reported by Amol Hatwar (rubygem) | May 8th, 2008 @ 06:21 AM | in 2.1.1
Hi,
I am on edge, and after a recent git pull started facing problems with controllers. Here's a screendump of whats happening...
amol@casper:~/projects/web/juggle$ script/generate controller dumdum::test
create app/controllers/dumdum
create app/helpers/dumdum
create app/views/dumdum/test
create test/functional/dumdum
create app/controllers/dumdum/test_controller.rb
create test/functional/dumdum/test_controller_test.rb
create app/helpers/dumdum/test_helper.rb
amol@casper:~/projects/web/juggle$ script/generate controller dumdum::paint
The name 'dumdum' is reserved by Ruby on Rails.
Please choose an alternative and run this generator again.
Suggestions:
dumdum bullet
To cut it short, I cant have more than one controller class in a module by using the generator... which defeats the purpose of modularized controllers in the first place.
I should be ready to submit a patch with some help...
Comments and changes to this ticket
-
josh May 8th, 2008 @ 06:20 AM
- Assigned user set to josh
- State changed from new to open
Verified. Post a fix w/ tests and I'll get it in for ya.
$ script/generate controller admin::people create app/controllers/admin create app/helpers/admin create app/views/admin/people create test/functional/admin create app/controllers/admin/people_controller.rb create test/functional/admin/people_controller_test.rb create app/helpers/admin/people_helper.rb $ script/generate controller admin::projects The name 'admin' is reserved by Ruby on Rails. Please choose an alternative and run this generator again. Suggestions:
-
Amol Hatwar (rubygem) May 8th, 2008 @ 08:02 PM
Thanks for verifying the bug quickly :o). I couldn't find much time to dig deep into it today. The situation may stay the same till after the weekend.
I think, this bit of code from line 169 onwards of the file: railties/lib/rails_generator/commands.rb is acting funny.
-- BEGINS --
# Extract the last Module in the nesting. last = nesting.inject(Object) { |last, nest| break unless last.const_defined?(nest) last.const_get(nest) }
-- ENDS --
It doesn't really return the last module in most cases...
-
Amol Hatwar (rubygem) May 12th, 2008 @ 02:30 AM
OK, I seem to have gotten rid of this bug to some extent. What I couldn't fix (yet), is having a controllers nested within modules with the same names which is allowed in Rails 2.0.2
For getting that behavior in, I guess we'll have to store entire module hierarchies and run checks on them... or, perhaps drop collision checking entirely :(
git binary patch file attached
-
josh May 13th, 2008 @ 10:04 PM
- Milestone set to 2.1.1
- State changed from open to resolved
-
rwl June 1st, 2008 @ 02:07 AM
hey guys, been having trouble with this, too. switching braches to v2.1.0_RC1 got it working, but not exaclty a longterm solution.
what did you guys end up doing? or do i just need to modify the nested name?
-
rwl June 1st, 2008 @ 11:12 AM
there was a patch to the main branch today that redefined the error. i will build a test app to try it out.
-
Amol Hatwar (rubygem) June 2nd, 2008 @ 01:20 AM
I think I was able to fix it. The patch is already live on edge...
-
Claudio Poli July 22nd, 2008 @ 12:53 PM
- Tag set to generators, railties
tried today, same error (edge)
-
Claudio Poli July 22nd, 2008 @ 01:44 PM
hrm.. problem got solved by commenting helper :all in ApplicationController (rails default).
-
Michael Trim July 23rd, 2008 @ 11:18 PM
- Tag changed from generators, railties to bug, generators, railties
Shouldn't this ticket be reopened, since the patch has been reverted? (In any case the patch doesn't do the right thing as far as I can tell.)
Like kain, I find it works if helper :all in ApplicationController is commented. I'm not sure why ApplicationController needs to be loaded to run the generator, but obviously when the helpers get loaded any Modules that they are in are present so the generator complains.
-
ronin-16982 (at lighthouseapp) September 16th, 2008 @ 09:00 PM
- Tag changed from bug, generators, railties to bug, generators, railties
-
ronin-16982 (at lighthouseapp) September 16th, 2008 @ 09:16 PM
Ok, no need to reopen since it seems to be fixed in egde and 2.1.1. Both testcases (from this ticket and from #545) work for me.
Sorry for noise...
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>
People watching this ticket
Attachments
Tags
Referenced by
- 1059 Bug in script/generate Actually this seems to be a duplicate of #138 but it is r...
- 545 Bug colliding classes (when they shouldn't) #138 - applied then reverted