Topic: How to get module_name/controller name inside controller

Hi,
I couldn't find a way to get the module_name/controller_name while I'm in a controller. I know controller_name, but it only returns the controller's name without the module name.
Thanks for your help.

Re: How to get module_name/controller name inside controller

What do you mean by module_name? The helper module? Or do you mean model?

Railscasts - Free Ruby on Rails Screencasts

Re: How to get module_name/controller name inside controller

As many, I develop an application with "admin" section. I placed controllers related to admin in a "subdirectory" under app/controllers (i.e. app/controllers/admin). By convention, Rails assumes that controllers in subdirectory admin are in a module named after the subdirectory i.e. "Admin". So the controller welcome located in app/controllers/admin/welcome_controller has the name Admin::Welcome. Controller_name only returns welcome, without Admin since Admin is not a part of the name of the controller.
My question is: is there a way to get (a method) the 'Admin' part of the name from inside the controller? And how :-).
Is this clearer?

Re: How to get module_name/controller name inside controller

That makes sense. Try this in a controller:

self.class.to_s

I think that includes the module (along with the full class name) so you'll need to parse it.

Railscasts - Free Ruby on Rails Screencasts

Re: How to get module_name/controller name inside controller

Yess. I knew it couldn't be difficult. Many thanks.
/p