# Template paths and view paths with namespaced controllers?

**URL:** <https://www.ruby-forum.com/t/template-paths-and-view-paths-with-namespaced-controllers/148451>\
**Category:** Rails\
**Created:** [September 12, 2008, 11:38pm UTC](https://www.ruby-forum.com/t/template-paths-and-view-paths-with-namespaced-controllers/148451 "2008-09-12T23:38:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danimal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bb73d2/32.png) [@Danimal](https://www.ruby-forum.com/u/Danimal)\
**Post date:** [September 12, 2008, 11:38pm UTC](https://www.ruby-forum.com/t/template-paths-and-view-paths-with-namespaced-controllers/148451/1 "2008-09-12T23:38:51Z")

</div>

Hello!

So I’ve got a confusing situation… I’ve got some controllers  
namespaced by account types, for example “Buyer” and “Seller”. I want  
to have some controllers in either namespace look in a common  
directory first for views and then within their namespaced views. I  
can’t figure out how to do this, though. I can set a global  
before\_filter and append or prepend to the view\_path. For example, if  
I have:

Seller::UsersController \< ApplicationController  
def index  
end  
end

Then I get:

Missing template seller/users/index.html.erb in view path …/  
myrailsapp/app/views:/…myrailsapp/app/views/common

See the problem? It’s looking in “seller/users”, not just “users”, so  
even if I move the code into app/views/common, it would need to be in  
“app/views/common/sellers/users/” which doesn’t make it common across  
sellers and buyers.

What I’m trying to do is have the above scenario use a view path as:  
[/app/views/sellers/users/, /app/views/common/users/]

That way, I can put common code in common for user views across the  
namespaces, but then if I want, I can put a view in the namespaced  
path and it will pick that up first.

I’m assuming (hoping?) there’s some way to tell a namespaced  
controller to not look in the namespaced view path?

Thanks for any help anyone can provide,

-Danimal

---

<div class="post-metadata">

**Author:** ![Danimal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/bb73d2/32.png) [@Danimal](https://www.ruby-forum.com/u/Danimal)\
**Post date:** [September 13, 2008, 12:23am UTC](https://www.ruby-forum.com/t/template-paths-and-view-paths-with-namespaced-controllers/148451/2 "2008-09-13T00:23:31Z")

</div>

As added info, it’s really not a view path problem, but a template  
path problem, as I see it. When in a namespace, Rails appends the  
folder for the namespace to template calls by default. So what I’m  
trying to do is find a way to override that. I know that I can just do  
a:

render :template =\> “users/index”

and if my view\_path is set as:

[/app/views/sellers/, /app/views/common/]

Then it would work… but then I’d have to _explicitly_ call the  
render :template call for EVERY action in my controller within the  
namespace.

I’m gonna go read up on render and see what I can find.

I welcome input here. 🙂

-Danimal
