#138 √ resolved
Amol Hatwar (rubygem)

script/generate glitch for controllers in modules

Reported by Amol Hatwar (rubygem) | May 7th, 2008 @ 04:47 PM | 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

  • Joshua Peek

    Joshua Peek May 8th, 2008 @ 12:20 AM

      • → State changed from “new” to “open”
      • → Assigned user changed from “” to “Joshua Peek”

    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)

    Amol Hatwar (rubygem) May 8th, 2008 @ 02: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)

    Amol Hatwar (rubygem) May 11th, 2008 @ 08:30 PM

    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

  • Joshua Peek

    Joshua Peek May 13th, 2008 @ 04:04 PM

      • → State changed from “open” to “resolved”
      • → Milestone changed from “” to “2.1.1”
  • rwl

    rwl May 31st, 2008 @ 08:07 PM

    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

    rwl June 1st, 2008 @ 05: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)

    Amol Hatwar (rubygem) June 1st, 2008 @ 07:20 PM

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

  • kain

    kain July 22nd, 2008 @ 06:53 AM

      • → Tag changed from “” to “generators railties”

    tried today, same error (edge)

    http://pastie.org/238523

  • kain
  • kain

    kain July 22nd, 2008 @ 07:44 AM

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

  • Michael Trim

    Michael Trim July 23rd, 2008 @ 05: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.

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

The Git repository resides at http://github.com/rails

Check out the current development trunk (Edge Rails) with:

git clone git://github.com/rails/rails.git

The latest development for the 1.2.x and 2.0.x releases are on the 1-2-stable and 2-0-stable branches.

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

Shared Ticket Bins