Get controller's module path

Hi,

Given a controller such as Maintenance::ProductsController, is there a
way to obtain the module section ‘Maintenance’ within a view.

I am planning to highlight the maintenance option from a common menu
whenever a controller from the Maintenance module is used.

Thanks, Andrew.

That’s ideal, thanks.

On 7-Jul-06, at 11:55 AM, Andrew E. wrote:

Hi,

Given a controller such as Maintenance::ProductsController, is there a
way to obtain the module section ‘Maintenance’ within a view.

I am planning to highlight the maintenance option from a common menu
whenever a controller from the Maintenance module is used.

There may be cleaner ways to do it but this ought to work:

controller.class.name.split(’::’).first

Regards,
Trevor

Trevor S.
http://somethinglearned.com

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