views:

125

answers:

2

If I declare local variables in a partial and then render the partial from another erb template, will the latter also have accces to those local variables?

+1  A: 

Short answer: Yes. You would theoretically be able to access the defined variable.

Longer answer: Don't define variables in views. Adding logic to the views (and therefore pushing it to the client) is really bad practice. Use models for your business logic and controllers for your action handling.

Bryan Woods
+2  A: 

I agree with Bryan's advice although I would also refer you to this answer which is a little bit more comprehensive on the same subject of where to define view-related variables.

flo