# Can I put seperate models into different directories

**URL:** <https://www.ruby-forum.com/t/can-i-put-seperate-models-into-different-directories/142514>\
**Category:** Rails\
**Created:** [July 8, 2008, 6:52pm UTC](https://www.ruby-forum.com/t/can-i-put-seperate-models-into-different-directories/142514 "2008-07-08T18:52:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Iain\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@Iain\_A](https://www.ruby-forum.com/u/Iain_A)\
**Post date:** [July 8, 2008, 6:52pm UTC](https://www.ruby-forum.com/t/can-i-put-seperate-models-into-different-directories/142514/1 "2008-07-08T18:52:22Z")

</div>

I have alot of models that are all linked. They are cluttering up my  
app/models directory. Is it possible to move some of my models into a  
sub directory. (i.e. app/models/items) Will Rails still pick these up?  
Do I need to change any configuration settings?

Thanks in advance

Iain A.

---

<div class="post-metadata">

**Author:** ![Iain\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@Iain\_A](https://www.ruby-forum.com/u/Iain_A)\
**Post date:** [July 8, 2008, 6:57pm UTC](https://www.ruby-forum.com/t/can-i-put-seperate-models-into-different-directories/142514/2 "2008-07-08T18:57:05Z")

</div>

On 8 Jul 2008, at 17:51, Iain A. wrote:

> I have alot of models that are all linked. They are cluttering up my  
> app/models directory. Is it possible to move some of my models into a  
> sub directory. (i.e. app/models/items) Will Rails still pick these up?  
> Do I need to change any configuration settings?

see  
[http://blog.hasmanythrough.com/2008/5/6/a-simple-alternative-to-namespaced-models](http://blog.hasmanythrough.com/2008/5/6/a-simple-alternative-to-namespaced-models)

Fred

---

<div class="post-metadata">

**Author:** ![Iain\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@Iain\_A](https://www.ruby-forum.com/u/Iain_A)\
**Post date:** [July 9, 2008, 4:40pm UTC](https://www.ruby-forum.com/t/can-i-put-seperate-models-into-different-directories/142514/3 "2008-07-09T16:40:32Z")

</div>

Mr. Cheung,  
I’ve tried all many of accomplishing of splitting my many models into  
subdirectories as displayed in the link you provide and one other.  
Each time I get an error message such as;

LoadError in Evidence/dispcodesController#index  
Expected D:/Rails/itracker/app/models/evidence/dispcode.rb to define  
Evidence::Dispcode

The two approaches I’ve tried are;

1. config.load\_paths += %W( #{RAILS\_ROOT}/app/models/evidence) =  
Josh’s approach
2. Dir.glob(“#{RAILS\_ROOT}/app/models/\*\*/\*”).each {|d|  
config.load\_paths \<\< d if File.directory?(d) }  
I wouldl be thrilled to make this work for all of the reaons that Josh  
explained. Note that all of the controllers are in sub folders to  
reflect their function.  
Thank you,  
Kathleen

On Jul 8, 10:56 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Iain\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/6bbea6/32.png) [@Iain\_A](https://www.ruby-forum.com/u/Iain_A)\
**Post date:** [July 9, 2008, 5:33pm UTC](https://www.ruby-forum.com/t/can-i-put-seperate-models-into-different-directories/142514/4 "2008-07-09T17:33:28Z")

</div>

Frederick C. wrote:

> see  
> [has\_many :through - A simple alternative to namespaced models](http://blog.hasmanythrough.com/2008/5/6/a-simple-alternative-to-namespaced-models)
> 
> Fred

I’m sure someone blogged about that way before him…

> **[Cleaning Up Your Models Folder](http://rudyonrails.blogspot.com/2007/06/cleaning-up-your-models-folder.html)**
>
> I love really complex applications. It feels safe and warm knowing that your code relies on 20 database tables, and maybe some of those have...

albeit a horrible looking, poorly maintained, blogger blog.
