I know Rails doesn't support nested has_many :through relationships, though there's been talk and an open ticket about a patch since as early as Rails 2.
I did come across a plugin that's pretty slick, but the master branches don't work with Rails 3 and I'm hesitant to use it for mission critical tasks in the app hence the lack of active recent development. So -- what's the best way to deal with these relations.
class Author < ActiveRecord::Base
has_many :contracts
has_many :products, :through => :contracts
class Product < ActiveRecord::Base
has_many :contracts
has_many :orders
has_many :authors, :through => :contracts
class Contracts < ActiveRecord::Base
belongs_to :author
belongs_to :product
So, all the being what it is it would be great to be able to get at orders this by adding this to the Author model:
has_many :orders, :through => :products
But alas, you cannot -- at least without the plugin. So, my question is what's the best approach to accessing all of an author's orders when the only association is between the join model, Contracts?