-
Notifications
You must be signed in to change notification settings - Fork 179
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
Instance Variables and Re-used Objects #124
Labels
Comments
Ref #125 |
I agree that finder should returns fresh instance of |
Hi, issue still happen in |
No progress yet. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I run into some trouble with ActiveHash when I set some per-request data on instance variables of an ActiveHash instance. I expected the ActiveHash finder methods to return fresh objects the way ActiveRecord does when you call
find
orwhere().first
or whatnot.I wrote a patch that separates the original state of the records in an ActiveHash sub-class from the records that are being passed around in the rest of the application. There is a bit of memory overhead to passing cloned objects instead of references to the same object, but that is true for ActiveRecord as well and it does not gum things up too much. I will submit a PR so you guys can have a look.
Alternatively to cloning objects, ActiveHash could freeze the records so they raise errors when developers try to set instance variables on them. This would give developers a better notion that the object they are using is not a clean/fresh copy like they'd expect it to be from ActiveRecord.
The text was updated successfully, but these errors were encountered: