Re: Get current controller name/action name from view

Ruby Freak
2008-05-11T16:25:34Z

Here is a link to what I think you are looking for

http://www.postal-code.com/mrhappy/blog/2007/01/18/rails-knowing-the-current-action-in-a-view/

Good luck.

On May 10, 11:22 pm, michael_teter
<michael.te...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> 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.