Namespaced layouts?


Is it just me or are layouts not namespaced automatically?

For example, using the typical namespaced admin section, I have:

apps/controllers/admin/users_controller.rb # for example

I then added this:

But it won’t use that layout… it’s looking for:

Why are views namespaced but layouts aren’t? There are lots of
“solutions” to this, I know, but I’m trying to understand why Rails
won’t look at “apps/views/admin/layouts/” for layouts within the admin

Or maybe I’m missing something?



Somewhat of an answer, somewhat of a new question…

It looks like layouts use namespacing, but “backwards” from everything
else. In other words, given my namespaced “admin”, It would look for
layouts in:


I’m wondering why that way and not:


The advantage to the latter would be that layouts and views would all
“live” under the admin folder. Ahh well.

Any insight on the why? I.e. why it is this way?


My guess is that layouts span across controllers and views…aka
namespaces. I have one layout for my entire app mostly. And where I
have another layout is for public pages, but these layout are in no
way controller specific. Thou I do see apps where this makes sense.


The application layout is for the entire application and it doesn’t
care about what namespace you’re in. If you really wanted a different
layout you could use the layout method in your controller to tell it
which one you want.

Ryan B.
Skype: radarlistener
MSN & Gtalk: [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs