This project is archived and is in readonly mode.
Backport :inverse_of from 3.0 to 2.3.x
Speaking to Eloy Durán on IRC it turned out that some other issues raised against 2.3.x would be solved more easily if the :inverse_of functionality was available.
The attached diff is simply the 3 commits to edge that implemented :inverse_of correctly merged onto 2-3-stable. They didn't apply cleanly and there were some conflicts that need resolving.
It should run a green test suite.
Comments and changes to this ticket
Also, note that George Ogata has a couple of other tickets (, ) about improving the inverse_of functionality. We should probably apply them to edge and 2-3-stable as well.
Um... that 2nd link should be to https://rails.lighthouseapp.com/projects/8994/tickets/3513-inverse_... not back to this one.
Tested both my patches on top of Murray's patch on 2-3-stable. The whole stack applies cleanly and the tests pass. It's also quite a simple modification to ActiveRecord all up.
Not sure what the above mentioned issues are that would be aided by inverse associations, but I'm keen to see this functionality in sometime soon. Until then, I have a plugin which backports it for 2.x apps to use right now, for anyone that's interested.
- Assigned user changed from Eloy Duran to Michael Koziarski
- Milestone set to 2.3.6
Thanks for the work Murphy! The most heard ‘issue’ is that people that use NestedAttributes can’t validate the presence of the parent. Also in multiple cases I really wanted to have access to the parent during building an associated record.
I’ve applied the patch, plus a patch from master that adds tests for the aforementioned validation problem.
I’ve also checked George's patches, they indeed apply and the tests run. But I'd like to know if anyone else has been using these patches on a real app before I push them? Besides George that is ;)
All in all, since 2.3.5 has recently been released, I think it would be best that if this will be applied to 2.3.x we do it asap. So people have time to actually test it a while before 2.3.6 is released.
I think it's safe to say my patches haven't been used much by others yet. I only wrote them recently.
That said, one is just a one-line bug fix. The polymorphic support is a little more involved - your call. I agree sooner would be better, though, for the reason you cited.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>