This project is archived and is in readonly mode.

#2417 ✓wontfix
Jordan Van Schyndel

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

Reported by Jordan Van Schyndel | April 4th, 2009 @ 07:48 PM | in 2.x

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

Comments and changes to this ticket

  • Jordan Van Schyndel

    Jordan Van Schyndel April 4th, 2009 @ 07:50 PM

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

  • Jordan Van Schyndel

    Jordan Van Schyndel April 4th, 2009 @ 07:53 PM

    • 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"”
  • Ryan Bigg

    Ryan Bigg April 29th, 2010 @ 10:34 PM

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

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>

Pages