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
inverse_of not working with has_many #3223
Comments
Does it work when you use addresses[0] instead of addresses.first? I think the implementation of :inverse_of doesn't work for the code example given in the documentation, since has_many's #first method always invokes a new query that is not cached. |
Is this still an issue? |
For me yes (3.0.12), https://gist.github.com/445969 |
@korny thanks for the adresses[0] hint. I spent quite a while wondering why my code wasn't using the inverse_of info. Inverse_of wont work if you use any query method to fetch any object? In a sense this is bit annoying.
Is there a way to do this cleanly or do I really need to have the Btw I updated the railsdocs according to the info in this issue: https://github.com/lifo/docrails/commit/121cf33eac5467ec01035af40f92ea4480ca4045 |
I reverted that commit in docrails |
This has been fixed in master and 3-2-stable with 7377 patch, let us know if you still have issues with that, thanks! |
Fixed bug in the example code. A bit related to rails issue in rails#3223
When using the inverse_of with a has_one it won't instantiate another object, but it will instantiate a new object when using has_many.
Those are the classes that I used to test this, in a brand new rails app:
https://gist.github.com/121fb94c31494ce8c90d
The text was updated successfully, but these errors were encountered: