
Add belongs_to :through
Reported by Dan Kubb (dkubb) | June 27th, 2008 @ 09:46 PM
I'd like to see a belongs_to :through option added, where you could do stuff like this:
belongs_to :order
belongs_to :customer, :through => :order
The brute force approach could be to simply go: self.order.customer under the hood, which will perform two queries when self.customer is called.
A more elegant approach would be when self.customer is called to make a query that links the Order and Customer models (since self already knows the order_id) and retrieves the Customer in a single query.
It should also be possible to layer :through statements on top of each other any number of levels deep (the same as has :through is supposed to work), eg:
belongs_to :order
belongs_to :customer, :through => :order
belongs_to :affiliate, :through => :customer
Comments and changes to this ticket
-
Jonathan Stott (namelessjon) November 30th, 2008 @ 09:59 AM
- Assigned user cleared.
- State changed from new to open
-
Dan Kubb (dkubb) November 30th, 2008 @ 12:13 PM
- Assigned user set to Dan Kubb (dkubb)
Please note this is something we'll be working on in the dkubb/dm-core branch. I will accept responsibility for this now.
-
Dan Kubb (dkubb) December 4th, 2008 @ 03:40 AM
- State changed from open to not-applicable
I am going to close this ticket, since i submitted it. Should not use LH as a TODO list. Marking as not-applicable, although it will make it into dkubb/dm-core branch at some point in the next month or two.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »