This might be a slightly odd question, but I was wondering if anyone know a Rails shortcut/system variable or something which would allow me to keep track of which controller is serving a page and which model is called by that controller. Obviously I am building the app so I know, but I wanted to make a more general plugin that would able to get this data retroactively without manually going through it.
Is there any simple shortcut for this?
The controller and action are defined in
paramsasparams[:controller]andparams[:action]but there is no placeholder for “the model” as a controller method may create many instances of models.You may want to create some kind of helper method to assist if you want:
You would have to explicitly set the model when you load it when servicing a request: