# Subfolders in app/models

**URL:** <https://www.ruby-forum.com/t/subfolders-in-app-models/75799>\
**Category:** Rails\
**Created:** [November 13, 2006, 4:29pm UTC](https://www.ruby-forum.com/t/subfolders-in-app-models/75799 "2006-11-13T16:29:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joergd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@joergd](https://www.ruby-forum.com/u/joergd)\
**Post date:** [November 13, 2006, 4:29pm UTC](https://www.ruby-forum.com/t/subfolders-in-app-models/75799/1 "2006-11-13T16:29:58Z")

</div>

Hi,

I have many many models ('cos of SIngle Table Inheritance), and I want  
to organize the various subclasses together in subfolders in the  
app/models folder.

SO e.g.

app/models/status.rb  
app/models/statuses/open.rb  
app/models/statuses/closed.rb

This USED to work in an older revision of Rails, but no longer works in  
Edge.

How can I make this work, so that Rails automagically recognizes my  
subclassed models in the app/models/statuses subfolder … ?

Thanks  
Joerg

---

<div class="post-metadata">

**Author:** ![joergd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@joergd](https://www.ruby-forum.com/u/joergd)\
**Post date:** [November 14, 2006, 12:20am UTC](https://www.ruby-forum.com/t/subfolders-in-app-models/75799/2 "2006-11-14T00:20:24Z")

</div>

Joerg D. wrote:

> Hi,
> 
> I have many many models ('cos of SIngle Table Inheritance), and I want  
> to organize the various subclasses together in subfolders in the  
> app/models folder.
> 
> SO e.g.
> 
> app/models/status.rb  
> app/models/statuses/open.rb  
> app/models/statuses/closed.rb
> 
> This USED to work in an older revision of Rails, but no longer works in  
> Edge.
> 
> How can I make this work, so that Rails automagically recognizes my  
> subclassed models in the app/models/statuses subfolder … ?
> 
> Thanks  
> Joerg

You should have a line in your environment.rb that is commented out that  
says something about load\_paths:

# Add additional load paths for your own custom dirs

config.load\_paths += ["#{RAILS\_ROOT}/app/models/sweepers/"]

Add your custom load paths there.

---

<div class="post-metadata">

**Author:** ![joergd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@joergd](https://www.ruby-forum.com/u/joergd)\
**Post date:** [November 14, 2006, 8:37am UTC](https://www.ruby-forum.com/t/subfolders-in-app-models/75799/3 "2006-11-14T08:37:03Z")

</div>

Works thanks. I was just under the impression that it automatically  
includes all subfolders as well … well, that’s how it used to work  
anyway. Shot.

Alex W. wrote:

> You should have a line in your environment.rb that is commented out that  
> says something about load\_paths:
> 
> # Add additional load paths for your own custom dirs
> 
> config.load\_paths += ["#{RAILS\_ROOT}/app/models/sweepers/"]
> 
> Add your custom load paths there.

---

<div class="post-metadata">

**Author:** ![joergd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/51bf81/32.png) [@joergd](https://www.ruby-forum.com/u/joergd)\
**Post date:** [November 14, 2006, 11:52am UTC](https://www.ruby-forum.com/t/subfolders-in-app-models/75799/4 "2006-11-14T11:52:15Z")

</div>

It used to. I believe it was removed for security reasons  
  
Joerg D. wrote:

> ```
> Works thanks. I was just under the impression that it 
> automatically
> includes all subfolders as well ... well, that's how it used to work
> anyway. Shot.
> 
> Alex W. wrote:
> ```
> 
> > ```
> > You should have a line in your environment.rb that is 
> > commented out that
> > says something about load_paths:
> > # Add additional load paths for your own custom dirs
> > 
> > config.load\_paths += ["#{RAILS\_ROOT}/app/models/sweepers/"]
> > 
> > Add your custom load paths there.
> > ```
> 
> ```
> 
> ```

  
--~--~---------~--~----~------------~-------~--~----~  
&nbsp;You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.   
 To post to this group, send email to removed\_email\_address@domain.invalid   
 To unsubscribe from this group, send email to removed\_email\_address@domain.invalid   
 For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en   
 -~----------~----~----~----~------~----~------~--~---
