has_many :through polymorphic

Hi All,

I have the following arrangement:

class PickAndPackRequest < ActiveRecord::Base
  has_many :transactions, :as => :request
  has_many :postings, :through => :transactions
end

class Transaction < ActiveRecord::Base
  belongs_to :request, :polymorphic => true
  has_many :postings
end

class Posting < ActiveRecord::Base
  belongs_to :transaction
end

But when I ask for PickAndPackRequest.find(:first).postings.find(:all)
it fails with:

  Mysql::Error: Unknown column 'transactions.transaction_id' in 'on
clause'

It generates the following SQL (which appears to be incorrect):

  SELECT postings.* FROM postings INNER JOIN transactions ON
postings.id = transactions.transaction_id WHERE
((transactions.request_id = 14) AND (transactions.request_type =
'PickAndPackRequest'))

The "ON" clause appears to be wrong, I would have thought it would be:

    ON postings.transaction_id = transaction.id

Can anybody point out what I'm doing wrong, because I'm stumped!

Cheers

Matthew.

http://blog.hasmanythrough.com/2006/4/3/polymorphic-through

Thanks for the reply, however I'm pretty confident that this isn't the
case that is covered in that article.

The article is talking about "the other side of" a
polymorphic :through. That's not what I've got. If I was asking for
all the Requests of a Transaction (of which there are many kinds of
Request) then that would be "the other side" and could be solved as
suggested in the article.

Cheers

Matthew.