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.