Which action?

Hi,

I’ve got a partial that I call from more than one view. I need it to be
slightly different when called from one of the views. Does rails set a
variable to tell the partial which action or view is calling it, and if
so, how?

Thank you.

Regards,
Rich

You can get the action from the params hash, params[:action]

Duzenbury, Rich wrote:

Rich


Sincerely,

William P.

Hi,

<%= controller.action_name %>

Thanks.

Regards,
Rich

On 9/26/07, Duzenbury, Rich [email protected] wrote:

Hi,

I’ve got a partial that I call from more than one view. I need it to be
slightly different when called from one of the views. Does rails set a
variable to tell the partial which action or view is calling it, and if
so, how?

You’ve figured out how to get the action name, but I would suggest
that this technique tends to make your code very “brittle”. A better
approach might be to pass a variable to the partial through the call
to render() using the :locals option.