This project is archived and is in readonly mode.
Backport :inverse_of from 3.0 to 2.3.x
Reported by Murray Steele | December 1st, 2009 @ 09:14 PM | in 2.3.6
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
-
Murray Steele December 1st, 2009 @ 09:21 PM
Also, note that George Ogata has a couple of other tickets ([1], [2]) about improving the inverse_of functionality. We should probably apply them to edge and 2-3-stable as well.
[1] https://rails.lighthouseapp.com/projects/8994/tickets/3520-add-inve... [2] https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets...
-
Murray Steele December 1st, 2009 @ 09:24 PM
Um... that 2nd link should be to https://rails.lighthouseapp.com/projects/8994/tickets/3513-inverse_... not back to this one.
-
George Ogata December 2nd, 2009 @ 06:26 AM
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.
-
Eloy Duran December 2nd, 2009 @ 07:37 PM
- 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.
http://github.com/Fingertips/rails/commits/2-3-stable
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.
-
George Ogata December 4th, 2009 @ 06:57 AM
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.
-
Murray Steele December 17th, 2009 @ 10:04 AM
Updated the patch to also include the patch committed to master that resolves [2815].
-
Eloy Duran December 28th, 2009 @ 08:49 PM
- State changed from new to resolved
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>
People watching this ticket
Attachments
Tags
Referenced by
- 3588 :autosave => true + accepts_nested_attributes_for = circular validation & blown stack I’m actually pretty glad you run into this problem, as yo...
- 5118 Not saved children does not have parent object in has many association Thank you. It looks like after https://rails.lighthouseap...