oo00oo
1
Is it possible to determine which action call the function ?
In example, func_test in ApplicationController could determine which
action from SiteController is calling her ?
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
oo00oo
2
if action_name == ‘index’
–
Kent
oo00oo
3
I can’t check this at the moment, but I think Ruby supports this:
def test
caller
end
test # should give the object that called test
http://www.ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/function.html#caller
Although, for your case, action_name is probably more suitable 
-Jonny.
oo00oo
4
No. action_name is not Ruby or ROR functionnality
oo00oo
6
Yes just test it, return an error. I need to pass an arguement ?
oo00oo
7
action_name is an attribute of class AtionController::Base. It does
not require an argument. Can you post the exception stack trace?
–
Kent
oo00oo
8
class TestController
def test
render :text => action_name
end
end
Works fine for me.
-Jonny.