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.

Non-namespaced Model in subfolder with same name gets named "Not a Class"

#2417

I have a non-namespaced model named "Team". It is located at

/app/models/team/team.rb

And it is loaded up into the application through a require in the ApplicationController:

require "models/team/team.rb"

Other models in the /team/ folder load fine, but upon loading the console, this error message occurs:

C:/repo/trunk/src/app/models/team/team.rb:1:TypeError: Team is not a class

Reported by Jordan Van Schyndel · April 4th, 2009 @ 07:48 PM

State: wontfix
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Jordan Van Schyndel
    Jordan Van Schyndel

    I should also mention that moving team.rb into the /models/ folder (away from the subfolder /team/) eliminates this error message.

    April 4th, 2009 @ 07:50 PM

  2. Jordan Van Schyndel
    Jordan Van Schyndel
    • Title changed from Model in subfolder with same name gets named "Not a Class" to Non-namespaced Model in subfolder with same name gets named "Not a Class"

    April 4th, 2009 @ 07:53 PM

  3. Ryan Bigg
    Ryan Bigg
    • State changed from new to wontfix

    Rails conventions are to place the file in app/models/team.rb due to autoloading of classes. If you cannot do this, I recommend placing this inside lib.

    April 29th, 2010 @ 10:34 PM