Get current controller name/action name from view

michael_teter
2008-05-11T06:22:17Z

Hi.

I swear I found this in the group archives, but now I cannot find this
in the group or elsewhere online!

In a view I would like to get the current controller name and action
that was used to get here.

For example, I have a template that I''m using from two different
controllers (and four different actions in each controller), such
as :controller => "my_view", :action => "current" (or
"expired", or
"fixed", etc.)

In this template I''m constructing some links to specific parameter
calls of this same template, and I need to know which controller was
used and what action was called to get us here.  I thought it was
something like this:

link_to "This Year", :controller => @controller.name, :action =>
@controller.action

The only thing I''ve found in the api that looks remotely similar is
UrlHelper''s current_page(), but that''s not quite what
I''m after, as I
don''t want to test something, I just WANT that something :)

Thanks.