oo00oo
2006-Mar-07 18:06 UTC
[Rails] Determine which action, which controller is calling ?
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 Young
2006-Mar-08 08:59 UTC
[Rails] Determine which action, which controller is calling ?
oo00oo wrote:> 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 > endYou should have access to the params[] hash, which contains the :controller and :action. -- Alex
oo00oo
2006-Mar-08 09:59 UTC
[Rails] Determine which action, which controller is calling ?
That''s it, thanks ! I create a simple before_filter like SiteController : before_filter :setup_params ApplicationController : def setup_params @par = params end> You should have access to the params[] hash, which contains the > :controller and :action. >