# Changing default path for layouts

**URL:** <https://www.ruby-forum.com/t/changing-default-path-for-layouts/181627>\
**Category:** Rails\
**Created:** [January 14, 2010, 10:51pm UTC](https://www.ruby-forum.com/t/changing-default-path-for-layouts/181627 "2010-01-14T22:51:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elricstorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/da6949/32.png) [@elricstorm](https://www.ruby-forum.com/u/elricstorm)\
**Post date:** [January 14, 2010, 10:51pm UTC](https://www.ruby-forum.com/t/changing-default-path-for-layouts/181627/1 "2010-01-14T22:51:23Z")

</div>

I’ve combed over the api, the classes, and even the file itself and I  
can’t seem to figure it out.

The closest line I can find that shows a relevant area of the layout I  
wish to change is undocumented in layout.rb of action\_controller:

def layout\_list #:nodoc:  
Array(view\_paths).sum([]) { |path| Dir["#{path.to\_str}/layouts/\*\*/\*"]  
}  
end

All starting layouts are pointing to app/views/layouts/\*\*/\*

I wish to point the initial starting point to:

public/themes/\*\*/\*

I already have my layouts being decided based off model values within an  
options set. I can easily point it to any new layout within the themes  
folder but the starting point is wrong.

How do I change this from the default starting point to the new starting  
point?

---

<div class="post-metadata">

**Author:** ![elricstorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/da6949/32.png) [@elricstorm](https://www.ruby-forum.com/u/elricstorm)\
**Post date:** [January 14, 2010, 11:01pm UTC](https://www.ruby-forum.com/t/changing-default-path-for-layouts/181627/2 "2010-01-14T23:01:45Z")

</div>

For clarification,

If I try to go to a page on my site which has the correct (route to the  
layout), I receive this error:

Missing layout public/themes/default/layouts/application.erb in view  
path app/views

So, the public/themes/default/layouts/application.erb is correct but the  
starting path of app/views is not.

I want the starting path to be changed from app/views to public/themes  
(but only for layouts), not for templates.

---

<div class="post-metadata">

**Author:** ![elricstorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/da6949/32.png) [@elricstorm](https://www.ruby-forum.com/u/elricstorm)\
**Post date:** [January 14, 2010, 11:32pm UTC](https://www.ruby-forum.com/t/changing-default-path-for-layouts/181627/3 "2010-01-14T23:32:31Z")

</div>

Okay, I managed to figure it out but I’m not sure it’s the best way of  
doing it. I placed the following code in environment.rb:

ActionController::Base.view\_paths = [“app/views”, “public/themes”]

So, it looks in both view paths and in app/views there are no layouts  
and in public/themes the layouts exist under the theme name. So far,  
everything is working great and I don’t see any performance issues.

But, the question is -

Is there a better way to do this?
