# Problematic admin/views

**URL:** <https://www.ruby-forum.com/t/problematic-admin-views/58910>\
**Category:** Rails\
**Created:** [April 27, 2006, 3:19am UTC](https://www.ruby-forum.com/t/problematic-admin-views/58910 "2006-04-27T03:19:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anabia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@anabia](https://www.ruby-forum.com/u/anabia)\
**Post date:** [April 27, 2006, 3:19am UTC](https://www.ruby-forum.com/t/problematic-admin-views/58910/1 "2006-04-27T03:19:37Z")

</div>

ok, i have a pretty almost finished (frontend) blog, i have defined an  
admin zone with authentication to add content, now im getting trouble  
with the views for the controllers in the admin zone, here you can see  
my file structure:

> **[ImageShack - Best place for all of your image hosting and image sharing needs](https://imageshack.com/)**
>
> Unlimited space to host images, easy to use image uploader, albums, photo hosting, sharing, dynamic image resizing on web and mobile.

and my admin controllers like this:

controllers/admin/admin\_controller.rb  
class Admin::AdminController \< ApplicationController  
…  
end

controllers/admin/articles\_controller.rb  
class Admin::ArticlesController \< Admin::AdminController  
…  
end

both works fine, the problem are the views, for example the  
controllers/articles\_controller.rb takes the view from  
views/layouts/articles.rhtml no problem, so the  
controllers/admin/articles\_controller.rb should take the view from but  
views/admin/layouts/articles.rhtml but isnt taking any viewÂ¡Â¡ not from  
there not from any place or folder in the admin view zone that i put the  
articles.rhtml file.

but it does take the little files that are usually called from  
@content\_for\_layout(show.rhtml, edit.rhtml, etc.) so i can add,delete,  
edit items without problems(if i see the source html of the browser i  
only see this part of htmlcode not a complete html page) but what is  
happening, why arent taking a main view?

note: the problem its present on every controller that i create on the  
admin zone, and when i create the admin/articles\_controller.rb the  
views/layouts/articles.rhtml(the frontend controller view) its  
overwritten(whyÂ¡?).

well,i have been working on this for a while and now im clueless about  
this, hope someone acn help with this, any help will be very apreciated.

🙂

---

<div class="post-metadata">

**Author:** ![anabia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@anabia](https://www.ruby-forum.com/u/anabia)\
**Post date:** [April 27, 2006, 4:01am UTC](https://www.ruby-forum.com/t/problematic-admin-views/58910/2 "2006-04-27T04:01:12Z")

</div>

So the views that work for Admin::ArticlesController are in  
“app/admin/articles/_.rhtml" and the ones that don;t work are in  
"app/admin/_.rhtml”

Views for ArticlesController: app/views/articles  
Views for Admin::ArticlesController: app/views/admin/articles

See how that works?

As for the layout, I don’t believe you can put layouts in a subfolder  
like that. I think the only layouts treated as layouts are in  
“app/views/layouts”

So create a file called “admin\_articles.rhtml” in “app/views/layouts”,  
and then in your Admin::ArticlesController put this near the top

layout: admin\_articles

---

<div class="post-metadata">

**Author:** ![anabia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/35a633/32.png) [@anabia](https://www.ruby-forum.com/u/anabia)\
**Post date:** [April 27, 2006, 6:46am UTC](https://www.ruby-forum.com/t/problematic-admin-views/58910/3 "2006-04-27T06:46:15Z")

</div>

by the naming conventions that are so mentioned, and using simple logic  
i thought that if a controller created in /controllers have its main  
view on /views/layouts, then a controller created on /controllers/admin  
will have its view on /views/admin/layout but well, weird rails thing.

now my layouts worked defining layout: admin/articles(i have  
articles.rhtml inside /views/admin).

Many thanks for this Alex 😉
