Forum: Ruby on Rails Gotchya with case sensativity and habtm

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
89441a6c74647d292f5cc951eae24cfa?d=identicon&s=25 Jack Christensen (Guest)
on 2005-12-12 20: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 Christensen
jackc@hylesanderson.com
This topic is locked and can not be replied to.