views:

36

answers:

1

In rails, page templates have their own controller which is called before a page is rendered (I think?).

Likewise, can I have a controller associated with a partial that is called before the partial is rendered?

I know you can pass local variable into a partial, but I want to run a good few lines of code to assign those local variables, which if I wasn't using a partial I would have put in the controller.

+1  A: 

This code that you want to run should be in a helper that can be called from the controller, or from the partial itself.

James Deville