Determining where a function is called from

I have a function that I use in my code in a number of places. It does
some database lookup, processes it and returns some content to display.
However, it needs to know where it was called from so that it can set up
some return links. Currently I call it from a controller like this:

@content = Content.getContent( "Hello from ", controller_name(),

action_name() )

I want to dry up the code and get rid of the controller and action calls
and move it to the model where it belongs, but the controller_name and
action_name functions are not available in the model.

My question, is there any way for the code in the model to discover
where the function was called from so that that information can be made
available to the function without having to explicitly pass it.

Hope someone can help,
– Will

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs