# How to tell if you are in a controller module

**URL:** <https://www.ruby-forum.com/t/how-to-tell-if-you-are-in-a-controller-module/83834>\
**Category:** Rails\
**Created:** [January 30, 2007, 5:31am UTC](https://www.ruby-forum.com/t/how-to-tell-if-you-are-in-a-controller-module/83834 "2007-01-30T05:31:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [January 30, 2007, 5:31am UTC](https://www.ruby-forum.com/t/how-to-tell-if-you-are-in-a-controller-module/83834/1 "2007-01-30T05:31:15Z")

</div>

I did the following:

script/generate controller admin/products

In my layout.rhtml template I want to use the admin style sheet. How can  
I tell if I am in the admin directory?

controller.controller\_name and controller.controller\_class\_name do not  
help at all, they don’t have admin anywhere in them.

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [January 30, 2007, 6:19pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-you-are-in-a-controller-module/83834/2 "2007-01-30T18:19:22Z")

</div>

Or you can just to params[‘controller’] in your layout .rhtml page and  
it  
should give you “admin”

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [January 30, 2007, 2:31pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-you-are-in-a-controller-module/83834/3 "2007-01-30T14:31:40Z")

</div>

Ben J. wrote:

> I did the following:
> 
> script/generate controller admin/products
> 
> In my layout.rhtml template I want to use the admin style sheet. How can  
> I tell if I am in the admin directory?
> 
> controller.controller\_name and controller.controller\_class\_name do not  
> help at all, they don’t have admin anywhere in them.
> 
> Thanks for your help.

Is there anything within the request object that will tell me I’m in the  
admin module / directory?

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [January 30, 2007, 6:36pm UTC](https://www.ruby-forum.com/t/how-to-tell-if-you-are-in-a-controller-module/83834/4 "2007-01-30T18:36:27Z")

</div>

Try controller.controller\_path. It should give you ‘admin/products’.

Julio
