@controller.controller_name will return a nicely formatted version of
the current controller name, and @controller.action_name will return
the current action name.
#controller_name:
http://api.rubyonrails.com/classes/ActionController/Base.html#M000149
#action_name:
http://api.rubyonrails.com/classes/ActionController/Base.html#M000157
good luck,
cb
On 5/22/05, Ben Myles <ben.myles-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
>
> Could someone tell me the best way to get the controller and action
> names from within the actual method? For example:
>
> class UserController < ApplicationController
> def list
> # print the controller and action name, ie. "user/list"
> end
> end
>
> I considered extracting it from the URI, however I''m hoping there
> might be a more general/accurate method?
>
> Thanks,
> Ben
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>