This project is archived and is in readonly mode.
script/generate glitch for controllers in modules
-
josh
- 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)
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)
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
-
rwl
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
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)
I think I was able to fix it. The patch is already live on edge...
-
Claudio Poli
another reference
-
Claudio Poli
hrm.. problem got solved by commenting helper :all in ApplicationController (rails default).
-
Michael Trim
- 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)
- Tag changed from bug, generators, railties to bug, generators, railties
-
ronin-16982 (at lighthouseapp)
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...
