How to get current method/action name from layout rhtml

There sure is a better soluition, but i added a before_filter in my application controller like this:

before_filter :set_canames

... private def set_canames @cname = controller_name @aname = action_name end

there probably is a better way, but it works.

In your views, you can use controller.controller_name and I’m sure there is a method for the action but I don’t know it off the top of my head. action_name would make the most sense.

Thorsten L wrote:

There sure is a better soluition, but i added a before_filter in my application controller like this:

before_filter :set_canames

... private def set_canames @cname = controller_name @aname = action_name end

there probably is a better way, but it works.

There was a recent post with similar information. I believe you do have access to 'controller' in the views (and layouts) therefore it is possible to use

controller.controller_name controller.action_name

Long