How to check the calling method?

Hey guys, quick question,

What's the easiest way in rail to check which action called another
method?

For example, say I wanted to run a method inside a method but only if
called by a specific top method.

i.e

def method_1
  # Only run if called by a specific method
  if <insert check calling method code here> == "specific method"
    method_2()
  end
end

Thanks

You can use caller inside the method, or perhaps params[:action].

I wouldn’t do it that way though. Just allow the method to take a parameter specifiying if that extra bit of code should be run.

-Jonathan.