# Nesting View Folders

**URL:** <https://www.ruby-forum.com/t/nesting-view-folders/175320>\
**Category:** Rails\
**Created:** [September 11, 2009, 6:22am UTC](https://www.ruby-forum.com/t/nesting-view-folders/175320 "2009-09-11T06:22:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdaoust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@mdaoust](https://www.ruby-forum.com/u/mdaoust)\
**Post date:** [September 11, 2009, 6:22am UTC](https://www.ruby-forum.com/t/nesting-view-folders/175320/1 "2009-09-11T06:22:53Z")

</div>

I like to nest my view folders the same way as my resources.

So, if I have:

map.resources :foos do |foos|  
foos.resources :bars  
end  
map.resources :sums

Then I’ll structure my view folders like:

views/  
foos/  
bars/  
sum/

To make this work, I need a tiny little extra line of code in the nested  
controller to tell rails where to look for the templates. Specifically:

prepend\_view\_path “app/views/foos”

Just curious about people’s views on this. Any feedback/criticisms on  
this method?

Thanks,

~ Mark

---

<div class="post-metadata">

**Author:** ![mdaoust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@mdaoust](https://www.ruby-forum.com/u/mdaoust)\
**Post date:** [September 11, 2009, 7:46am UTC](https://www.ruby-forum.com/t/nesting-view-folders/175320/2 "2009-09-11T07:46:51Z")

</div>

It’s an aesthetic decision, so…y’know, do what you want, but it’s  
not necessary since you’re introducing complexity in having to  
maintain a bunch of of prepend\_view\_path lines everywhere.

> **[Convention over configuration](https://en.wikipedia.org/wiki/Convention_over_configuration)**
>
> Convention over configuration (also known as coding by convention) is a software design paradigm used by software frameworks that attempts to decrease the number of decisions that a developer using the framework is required to make without necessarily losing flexibility and don't repeat yourself (DRY) principles.
> The concept was introduced by David Heinemeier Hansson to describe the philosophy of the Ruby on Rails web framework, but is related to earlier ideas like the concept of "sensible defa...

On Sep 10, 9:22 pm, Mark D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![mdaoust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@mdaoust](https://www.ruby-forum.com/u/mdaoust)\
**Post date:** [September 11, 2009, 9:00am UTC](https://www.ruby-forum.com/t/nesting-view-folders/175320/3 "2009-09-11T09:00:50Z")

</div>

Thanks Eric – the more I think about this, I’m thinking it’s _not_ a  
good idea actually…

---

<div class="post-metadata">

**Author:** ![mdaoust](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@mdaoust](https://www.ruby-forum.com/u/mdaoust)\
**Post date:** [September 11, 2009, 7:26pm UTC](https://www.ruby-forum.com/t/nesting-view-folders/175320/4 "2009-09-11T19:26:26Z")

</div>

Not to mention the confusion when you start nesting a resource under  
more than one parent; eg, you have foos/1/bars and woots/1/bars.

–Matt J.
