# Namespacing views simply and effectively?

**URL:** <https://www.ruby-forum.com/t/namespacing-views-simply-and-effectively/169541>\
**Category:** Rails\
**Created:** [June 5, 2009, 12:35am UTC](https://www.ruby-forum.com/t/namespacing-views-simply-and-effectively/169541 "2009-06-05T00:35:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [June 5, 2009, 12:35am UTC](https://www.ruby-forum.com/t/namespacing-views-simply-and-effectively/169541/1 "2009-06-05T00:35:37Z")

</div>

So, to help arrange the files in my application directory, I used a tip  
from this blog post:

[http://m.onkey.org/2007/12/9/namespaced-models](http://m.onkey.org/2007/12/9/namespaced-models)

Essentially, I moved all my controller, model and sweeper files into  
folders with names that described their general purpose, and then put a  
line like the following in environment.rb:

[“accounts”, “blog”, “support”].each do |path|  
[“models”, “controllers”, “sweepers”].each do |component|  
config.load\_paths += %W( #{RAILS\_ROOT}/app/#{component}/#{path} )  
end  
end

This worked out pretty well. Now, I want to figure out a way to do the  
same with views. I’ve experimented a bit with putting them in the same  
folders, under app/views, and pointing to them like:

before\_filter { |controller| controller.view\_paths = [“app/views/blog”]  
}

But this gets very messy - Rails starts looking for layouts and partials  
in the same place, even though those are shared among different parts of  
the site and shouldn’t be namespaced.

Does anyone have a suggestion? I have an annoyingly large number of view  
folders and files, and I want to neaten them up a bit.

Thanks!

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [June 5, 2009, 9:13pm UTC](https://www.ruby-forum.com/t/namespacing-views-simply-and-effectively/169541/2 "2009-06-05T21:13:43Z")

</div>

Nobody has any ideas?
