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.

script/generate glitch for controllers in modules

#138

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...

Reported by Amol Hatwar (rubygem) · May 8th, 2008 @ 06:21 AM

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

Activity

  1. josh
    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:  
    

    May 8th, 2008 @ 06:20 AM

  2. Amol Hatwar (rubygem)
    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...

    May 8th, 2008 @ 08:02 PM

  3. Amol Hatwar (rubygem)
    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

    May 12th, 2008 @ 02:30 AM

  4. josh
    josh
    • Milestone set to 2.1.1
    • State changed from open to resolved

    May 13th, 2008 @ 10:04 PM

  5. rwl
    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?

    June 1st, 2008 @ 02:07 AM

  6. rwl
    rwl

    there was a patch to the main branch today that redefined the error. i will build a test app to try it out.

    June 1st, 2008 @ 11:12 AM

  7. Amol Hatwar (rubygem)
    Amol Hatwar (rubygem)

    I think I was able to fix it. The patch is already live on edge...

    June 2nd, 2008 @ 01:20 AM

  8. Claudio Poli
    Claudio Poli
    • Tag set to generators, railties

    tried today, same error (edge)

    http://pastie.org/238523

    July 22nd, 2008 @ 12:53 PM

  9. Claudio Poli
  10. Claudio Poli
    Claudio Poli

    hrm.. problem got solved by commenting helper :all in ApplicationController (rails default).

    July 22nd, 2008 @ 01:44 PM

  11. Michael Trim
    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.

    July 23rd, 2008 @ 11:18 PM

  12. ronin-16982 (at lighthouseapp)
    ronin-16982 (at lighthouseapp)
    • Tag changed from bug, generators, railties to bug, generators, railties

    I also think this ticket should be reopened since the patch was reverted (see #545) and people still run into the problem (see #1059).

    September 16th, 2008 @ 09:00 PM

  13. ronin-16982 (at lighthouseapp)
    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...

    September 16th, 2008 @ 09:16 PM