Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top