# How does it know?

**URL:** <https://www.ruby-forum.com/t/how-does-it-know/64491>\
**Category:** Rails\
**Created:** [February 7, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/how-does-it-know/64491 "2006-02-07T19:35:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacob\_Ezzell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@Jacob\_Ezzell](https://www.ruby-forum.com/u/Jacob_Ezzell)\
**Post date:** [February 7, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/how-does-it-know/64491/1 "2006-02-07T19:35:36Z")

</div>

I’m a recent Ruby/rails initiate, coming from PHP. I’m working my way  
through the Agile web development book, (slowly) and I ran into a wierd  
bug where the method cart.empty! wasn’t being found when I tried to call  
it after loading my cart from the session hash. Then I left it alone  
for a while and now it works. ACK! 🙂

My question is, how does ruby/rails know what files to include so it can  
find the class I’m instantiating? I’m used to having to include all my  
files manually with php.

---

<div class="post-metadata">

**Author:** ![Jacob\_Ezzell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@Jacob\_Ezzell](https://www.ruby-forum.com/u/Jacob_Ezzell)\
**Post date:** [February 7, 2006, 7:44pm UTC](https://www.ruby-forum.com/t/how-does-it-know/64491/2 "2006-02-07T19:44:28Z")

</div>

If you put your files in the app/models directory, it will be  
auto-loaded, IF you give the file the same name as the class.

Jules

---

<div class="post-metadata">

**Author:** ![Jacob\_Ezzell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@Jacob\_Ezzell](https://www.ruby-forum.com/u/Jacob_Ezzell)\
**Post date:** [February 7, 2006, 8:41pm UTC](https://www.ruby-forum.com/t/how-does-it-know/64491/3 "2006-02-07T20:41:55Z")

</div>

Take a look at the stuff rails generates for you in the config  
directory… boot.rb, environment.rb, etc.

b
