Let me expose the problem with an example :
Cart model (as in : shopping cart)
class Cart < ActiveRecord::Base
has_one :bill
belongs_to :user
end
Bill model
class Bill < ActiveRecord::Base
belongs_to :cart
end
User
class User < ActiveRecord::Base
has_many :carts
has_many :bills, :through => :carts #<== Doesn't work... no user.bills for you!
end
Basically, because the "through" table links the destination table with a has_one relationship, ActiveRecord complains with : Invalid source reflection macro :has_one for has_many :bills, :through => :carts. Use :source to specify the source reflection.
Someone on Rails Trac already created a ticket about this issue 2 years ago. Can we expect this feature to be officially supported in the future? Let's hope so.
I think the rails core crew would welcome a patch for this. 😉
What Time said 🙂 Please submit the patch with tests on LightHouse.
Hey guys,
You’re right, I’ll do that
Hey, Frank. Any updates on this?
I was searching through Lighthouse for a ticket/patch but didn’t have any success. I’m looking for a patch re: this, too, I just don’t want to duplicate any effort… Thanks much !