Forum: Ruby on Rails Determine which action, which controller is calling ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
oo00oo (Guest)
on 2006-03-07 20:08
(Received via mailing list)
Hello,

Is it possible to determine wich :action , wich :controller is calling
the function   func_test   in ApplicationController ?

in class ApplicationController I have

def func_test
   if ( calling from index )
       return "1"     end

   if ( calling from contact )
       return "2"     end
end

and in class SiteController

def index
   @var = func_test
end

def contact
   @var = func_test
end

Thanks
Alex Y. (Guest)
on 2006-03-08 11:00
(Received via mailing list)
oo00oo wrote:
>
> def contact
>   @var = func_test
> end
You should have access to the params[] hash, which contains the
:controller and :action.
oo00oo (Guest)
on 2006-03-08 12:02
(Received via mailing list)
That's it, thanks !

I create a simple before_filter like

SiteController :
before_filter :setup_params

ApplicationController :
def setup_params
    @par = params
end
This topic is locked and can not be replied to.