Forum: Ruby on Rails Gotchya with case sensativity and habtm

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jack C. (Guest)
on 2005-12-12 21:07
(Received via mailing list)
Here's a gotchya that cost me a couple hours. Maybe this will help
someone else.

I had a model :User in a controller. This was code that pre-dated not
needing the model line for most cases. The problem was elsewhere it was
loaded as :user. Apparently, it does a case-sensative compare on what
has already been loaded. Because User != user in this it then loads
User.rb. On Windows, anyway, user.rb and User.rb are the same file. So
the file is loaded twice. It had a habtm association. habtm renames a
method and creates a new method which calls the old. The second time
this happens the old and new method will infinate loop upon each other.

So watch out for case issues or files may be loaded multiple times.

Hope this helps someone.

Jack C.
This topic is locked and can not be replied to.