-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are instance variables in cells overridden ? #1
Comments
It seems to me that the variables in the controller should not be visible at all inside the cells. Isn't that better encapsulation? I.e. if it isn't passed as an option to the cell, then it isn't visible. I've actually been burned by this in the past where I had cells silently depending on variables set in the controller. |
this is NOT the intended behaviour, but a serious bug! the cell view should never know anything about controller variables. guess the problem is inside ActionView::Base where controller variables are prefered in place of the passed local vars. damn- gotta fix that. |
fixed in bf49226 |
I'm sorry for the late reply, but I tested the source |
thank you, kinokuni. one thing we have to take into account is that controller ivars with no same-named cell ivar will still be accessible in the cell view, since an unspecified set of controller ivars have to be around in the view, for helpers, so we have to copy them. sucks, but i don't see any way around that if we want to stay forward-compatible. |
I have noticed that instance variables in cells are overridden
by those in the controllers of the same name while the cell is
being rendered from the template (although the variables in the cell
are used if the cell method returns string directly). Is this
the intended behavior? I think it would be better the
variables defined in cells are on the top.
The patch attached will make it so.
The text was updated successfully, but these errors were encountered: